-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Adds documentation for the new ISSN validator #2539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| Issn | ||
| ==== | ||
|
|
||
| .. versionadded:: 2.3 | ||
| The ISSN validation is new in Symfony 2.3. | ||
|
|
||
| Validates that a value is a valid `ISSN`_. | ||
|
|
||
| +----------------+-----------------------------------------------------------------------+ | ||
| | Applies to | :ref:`property or method<validation-property-target>` | | ||
| +----------------+-----------------------------------------------------------------------+ | ||
| | Options | - `message`_ | | ||
| | | - `caseSensitive`_ | | ||
| | | - `requireHyphen`_ | | ||
| +----------------+-----------------------------------------------------------------------+ | ||
| | Class | :class:`Symfony\\Component\\Validator\\Constraints\\Issn` | | ||
| +----------------+-----------------------------------------------------------------------+ | ||
| | Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IssnValidator` | | ||
| +----------------+-----------------------------------------------------------------------+ | ||
|
|
||
| Basic Usage | ||
| ----------- | ||
|
|
||
| .. configuration-block:: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| # src/JournalBundle/Resources/config/validation.yml | ||
| Acme\JournalBundle\Entity\Journal: | ||
| properties: | ||
| issn: | ||
| - Issn: ~ | ||
|
|
||
| .. code-block:: php-annotations | ||
|
|
||
| // src/Acme/JournalBundle/Entity/Journal.php | ||
| namespace Acme\JournalBundle\Entity; | ||
|
|
||
| use Symfony\Component\Validator\Constraints as Assert; | ||
|
|
||
| class Journal | ||
| { | ||
| /** | ||
| * @Assert\Issn | ||
| */ | ||
| protected $issn; | ||
| } | ||
|
|
||
| .. code-block:: xml | ||
|
|
||
| <!-- src/Acme/JournalBundle/Resources/config/validation.xml --> | ||
| <class name="Acme\JournalBundle\Entity\Journal"> | ||
| <property name="issn"> | ||
| <constraint name="Issn" /> | ||
| </property> | ||
| </class> | ||
|
|
||
| .. code-block:: php | ||
|
|
||
| // src/Acme/JournalBundle/Entity/Journal.php | ||
| namespace Acme\JournalBundle\Entity; | ||
|
|
||
| use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
| use Symfony\Component\Validator\Constraints as Assert; | ||
|
|
||
| class Journal | ||
| { | ||
| public static function loadValidatorMetadata(ClassMetadata $metadata) | ||
| { | ||
| $metadata->addPropertyConstraint('issn', new Assert\Issn()); | ||
| } | ||
| } | ||
|
|
||
| Options | ||
| ------- | ||
|
|
||
| message | ||
| ~~~~~~~ | ||
|
|
||
| **type**: ``String`` default: ``This value is not a valid ISSN.`` | ||
|
|
||
| The message shown if the given value is not a valid ISSN. | ||
|
|
||
| caseSensitive | ||
| ~~~~~~~~~~~~~ | ||
|
|
||
| **type**: ``Boolean`` default: ``false`` | ||
|
|
||
| The validator will allow ISSN values to end with a lower case 'x' by default. | ||
| When switching this to ``true``, the validator requires an upper case 'X'. | ||
|
|
||
| requireHyphen | ||
| ~~~~~~~~~~~~~ | ||
|
|
||
| **type**: ``Boolean`` default: ``false`` | ||
|
|
||
| The validator will allow non hyphenated ISSN values by default. When switching | ||
| this to ``true``, the validator requires an hyphenathed ISSN value. | ||
|
|
||
| .. _`ISSN`: http://en.wikipedia.org/wiki/Issn | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a new line after the last line to avoid bad diffs if someone adds another link in this article
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding a link to Wikipedia or similar to get more information on what an ISSN actually is? (similar to what is done in Luhn constraint)?