8000 minor #13960 Add doc for Isin constraint (VincentLanglet) · symfony/symfony-docs@a5f3a0f · GitHub
[go: up one dir, main page]

Skip to content

Commit a5f3a0f

Browse files
committed
minor #13960 Add doc for Isin constraint (VincentLanglet)
This PR was merged into the master branch. Discussion ---------- Add doc for Isin constraint Related to symfony/symfony#37565 Commits ------- 9b7bae9 Add doc for Isin constraint
2 parents 38edd48 + 9b7bae9 commit a5f3a0f

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

reference/constraints.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Validation Constraints Reference
6363
constraints/Bic
6464
constraints/Isbn
6565
constraints/Issn
66+
constraints/Isin
6667

6768
constraints/AtLeastOneOf
6869
constraints/Sequentially

reference/constraints/Isin.rst

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

reference/constraints/map.rst.inc

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

8586
Other Constraints
8687
~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)
0