Skip to content

Commit 9b7bae9

Browse files
Add doc for Isin constraint
1 parent ec43b0c commit 9b7bae9

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
@@ -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: 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
@@ -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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy