forked from symfony/symfony-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
Bic | ||
=== | ||
|
||
.. versionadded:: 2.8 | ||
The Bic constraint was introduced in Symfony 2.8. | ||
|
||
This constraint is used to ensure that a value has the proper format of a | ||
`Business Identifier Code (BIC)`_. BIC is an internationally agreed means to | ||
uniquely identify both financial and non-financial institutions. | ||
|
||
+----------------+-----------------------------------------------------------------------+ | ||
| Applies to | :ref:`property or method <validation-property-target>` | | ||
+----------------+-----------------------------------------------------------------------+ | ||
| Options | - `message`_ | | ||
| | - `payload`_ | | ||
+----------------+-----------------------------------------------------------------------+ | ||
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Bic` | | ||
+----------------+-----------------------------------------------------------------------+ | ||
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BicValidator` | | ||
+----------------+-----------------------------------------------------------------------+ | ||
|
||
Basic Usage | ||
----------- | ||
|
||
To use the Bic validator, simply apply it to a property on an object that | ||
will contain a Business Identifier Code (BIC). | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: php-annotations | ||
// src/AppBundle/Entity/Transaction.php | ||
namespace AppBundle\Entity; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
class Transaction | ||
{ | ||
/** | ||
* @Assert\Bic() | ||
*/ | ||
protected $businessIdentifierCode; | ||
} | ||
.. code-block:: yaml | ||
# src/AppBundle/Resources/config/validation.yml | ||
AppBundle\Entity\Transaction: | ||
properties: | ||
businessIdentifierCode: | ||
- Bic: | ||
message: This is not a valid Business Identifier Code (BIC). | ||
.. code-block:: xml | ||
<!-- src/AppBundle/Resources/config/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 http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> | ||
<class name="AppBundle\Entity\Transaction"> | ||
<property name="businessIdentifierCode"> | ||
<constraint name="Bic"> | ||
<option name="message"> | ||
This is not a valid Business Identifier Code (BIC). | ||
</option> | ||
</constraint> | ||
</property> | ||
</class> | ||
</constraint-mapping> | ||
.. code-block:: php | ||
// src/AppBundle/Entity/Transaction.php | ||
namespace AppBundle\Entity; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
class Transaction | ||
{ | ||
protected $businessIdentifierCode; | ||
public static function loadValidatorMetadata(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraint('businessIdentifierCode', new Assert\Bic(array( | ||
'message' => 'This is not a valid Business Identifier Code (BIC).', | ||
))); | ||
} | ||
} | ||
Available Options | ||
----------------- | ||
|
||
message | ||
~~~~~~~ | ||
|
||
**type**: ``string`` **default**: ``This is not a valid Business Identifier Code (BIC).`` | ||
|
||
The default message supplied when the value does not pass the BIC check. | ||
|
||
.. include:: /reference/constraints/_payload-option.rst.inc | ||
|
||
.. _`Business Identifier Code (BIC)`: https://en.wikipedia.org/wiki/Business_Identifier_Code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters