diff --git a/reference/constraints.rst b/reference/constraints.rst index 94077dd3052..6e31e80788a 100644 --- a/reference/constraints.rst +++ b/reference/constraints.rst @@ -50,6 +50,7 @@ Validation Constraints Reference constraints/Currency constraints/Luhn constraints/Iban + constraints/Bic constraints/Isbn constraints/Issn diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst new file mode 100644 index 00000000000..2c16b4aade6 --- /dev/null +++ b/reference/constraints/Bic.rst @@ -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 ` | ++----------------+-----------------------------------------------------------------------+ +| 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 + + + + + + + + + + + + + + + .. 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 diff --git a/reference/constraints/map.rst.inc b/reference/constraints/map.rst.inc index 686ad22bca5..71eac36479d 100644 --- a/reference/constraints/map.rst.inc +++ b/reference/constraints/map.rst.inc @@ -66,6 +66,7 @@ File Constraints Financial and other Number Constraints ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* :doc:`Bic ` * :doc:`CardScheme ` * :doc:`Currency ` * :doc:`Luhn `