8000 Add doc for Isin constraint · symfony/symfony-docs@80bb60a · GitHub
[go: up one dir, main page]

Skip to content

Commit 80bb60a

Browse files
Add doc for Isin constraint
1 parent b1fd71a commit 80bb60a

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

reference/constraints.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Validation Constraints Reference
6262
constraints/Bic
6363
constraints/Isbn
6464
constraints/Issn
65+
constraints/Isin
6566

6667
constraints/AtLeastOneOf
6768
constraints/Sequentially

reference/constraints/Isin.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
message
81+
~~~~~~~
82+
83+
**type**: ``string`` default: ``This value is not a valid International Securities Identification Number (ISIN).``
84+
85+
The message shown if the given value is not a valid ISIN.
86+
87+
You can use the following parameters in this message:
88+
89+
=============== ==============================================================
90+
Parameter Description
91+
=============== ==============================================================
92+
``{{ value }}`` The current (invalid) value
93+
=============== ==============================================================
94+
95+
.. include:: /reference/constraints/_payload-option.rst.inc
96+
97+
.. _`International Securities Identification Number (ISIN)`: https://en.wikipedia.org/wiki/International_Securities_Identification_Number

reference/constraints/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Financial and other Number Constraints
8080
* :doc:`Iban </reference/constraints/Iban>`
8181
* :doc:`Isbn </reference/constraints/Isbn>`
8282
* :doc:`Issn </reference/constraints/Issn>`
83+
* :doc:`Isin </reference/constraints/Isin>`
8384

8485
Other Constraints
8586
~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)
0