|
| 1 | +Isin |
| 2 | +==== |
| 3 | + |
| 4 | +Validates that a value is a valid |
| 5 | +`International Securities Identification Number (ISIN)`_. |
| 6 | + |
| 7 | +========== =================================================================== |
| 8 | +Applies to :ref:`property or method <validation-property-target>` |
| 9 | +Options - `groups`_ |
| 10 | +- `message`_ |
| 11 | +- `payload`_ |
| 12 | +Class :class:`Symfony\\Component\\Validator\\Constraints\\Isin` |
| 13 | +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsinValidator` |
| 14 | +========== =================================================================== |
| 15 | + |
| 16 | +Basic Usage |
| 17 | +----------- |
| 18 | + |
| 19 | +.. configuration-block:: |
| 20 | + |
| 21 | +.. code-block:: php-annotations |
| 22 | +
|
| 23 | +// src/Entity/UnitAccount.php |
| 24 | +namespace App\Entity; |
| 25 | +
|
| 26 | +use Symfony\Component\Validator\Constraints as Assert; |
| 27 | +
|
| 28 | +class UnitAccount |
| 29 | +{ |
| 30 | +/** |
| 31 | +* @Assert\Isin |
| 32 | +*/ |
| 33 | +protected $isin; |
| 34 | +} |
| 35 | +
|
| 36 | + .. code-block:: yaml |
| 37 | +
|
| 38 | +# config/validator/validation.yaml |
| 39 | +App\Entity\UnitAccount: |
| 40 | +properties: |
| 41 | +isin: |
| 42 | +- Isin: ~ |
| 43 | +
|
| 44 | + .. code-block:: xml |
| 45 | +
|
| 46 | +<!-- config/validator/validation.xml --> |
| 47 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 48 | +<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" |
| 49 | +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 50 | +xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> |
| 51 | +
|
| 52 | +<class name="App\Entity\UnitAccount"> |
| 53 | +<property name="isin"> |
| 54 | +<constraint name="Isin"/> |
| 55 | +</property> |
| 56 | +</class> |
| 57 | +</constraint-mapping> |
| 58 | +
|
| 59 | + .. code-block:: php |
| 60 | +
|
| 61 | +// src/Entity/UnitAccount.php |
| 62 | +namespace App\Entity; |
| 63 | +
|
| 64 | +use Symfony\Component\Validator\Constraints as Assert; |
| 65 | +use Symfony\Component\Validator\Mapping\ClassMetadata; |
| 66 | +
|
| 67 | +class UnitAccount |
| 68 | +{ |
| 69 | +public static function loadValidatorMetadata(ClassMetadata $metadata) |
| 70 | +{ |
| 71 | +$metadata->addPropertyConstraint('isin', new Assert\Isin()); |
| 72 | +} |
| 73 | +} |
| 74 | +
|
| 75 | +.. include:: /reference/constraints/_empty-values-are-valid.rst.inc |
| 76 | + |
| 77 | +Options |
| 78 | +------- |
| 79 | + |
| 80 | +.. include:: /reference/constraints/_groups-option.rst.inc |
| 81 | + |
| 82 | +message |
| 83 | +~~~~~~~ |
| 84 | + |
| 85 | +**type**: ``string`` default: ``This value is not a valid International Securities Identification Number (ISIN).`` |
| 86 | + |
| 87 | +The message shown if the given value is not a valid ISIN. |
| 88 | + |
| 89 | +You can use the following parameters in this message: |
| 90 | + |
| 91 | +=============== ============================================================== |
| 92 | +Parameter Description |
| 93 | +=============== ============================================================== |
| 94 | +``{{ value }}`` The current (invalid) value |
| 95 | +=============== ============================================================== |
| 96 | + |
| 97 | +.. include:: /reference/constraints/_payload-option.rst.inc |
| 98 | + |
| 99 | +.. _`International Securities Identification Number (ISIN)`: https://en.wikipedia.org/wiki/International_Securities_Identification_Number |
0 commit comments