Skip to content

Add doc for Isin constraint #13960

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 1 commit into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions reference/constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Validation Constraints Reference
constraints/Bic
constraints/Isbn
constraints/Issn
constraints/Isin

constraints/AtLeastOneOf
constraints/Sequentially
Expand Down
99 changes: 99 additions & 0 deletions reference/constraints/Isin.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Isin
====

Validates that a value is a valid
`International Securities Identification Number (ISIN)`_.

========== ===================================================================
Applies to :ref:`property or method <validation-property-target>`
Options - `groups`_
- `message`_
- `payload`_
Class :class:`Symfony\\Component\\Validator\\Constraints\\Isin`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsinValidator`
========== ===================================================================

Basic Usage
-----------

.. configuration-block::

.. code-block:: php-annotations

// src/Entity/UnitAccount.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;

class UnitAccount
{
/**
* @Assert\Isin
*/
protected $isin;
}

.. code-block:: yaml

# config/validator/validation.yaml
App\Entity\UnitAccount:
properties:
isin:
- Isin: ~

.. code-block:: xml

<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="App\Entity\UnitAccount">
<property name="isin">
<constraint name="Isin"/>
</property>
</class>
</constraint-mapping>

.. code-block:: php

// src/Entity/UnitAccount.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;

class UnitAccount
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('isin', new Assert\Isin());
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

.. include:: /reference/constraints/_groups-option.rst.inc

message
~~~~~~~

**type**: ``string`` default: ``This value is not a valid International Securities Identification Number (ISIN).``

The message shown if the given value is not a valid ISIN.

You can use the following parameters in this message:

=============== ==============================================================
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
=============== ==============================================================

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`International Securities Identification Number (ISIN)`: https://en.wikipedia.org/wiki/International_Securities_Identification_Number
1 change: 1 addition & 0 deletions reference/constraints/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Financial and other Number Constraints
* :doc:`Iban </reference/constraints/Iban>`
* :doc:`Isbn </reference/constraints/Isbn>`
* :doc:`Issn </reference/constraints/Issn>`
* :doc:`Isin </reference/constraints/Isin>`

Other Constraints
~~~~~~~~~~~~~~~~~
Expand Down