Skip to content

Commit

Permalink
Merge branch '2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Oct 12, 2015
2 parents 46096d3 + b03367c commit b13593e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
4 changes: 2 additions & 2 deletions create_framework/dependency-injection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,6 @@ micro-framework, and especially its `Application`_ class.

Have fun!

.. _`Pimple`: https://github.com/fabpot/Pimple
.. _`Pimple`: https://github.com/silexphp/Pimple
.. _`Silex`: http://silex.sensiolabs.org/
.. _`Application`: https://github.com/fabpot/Silex/blob/master/src/Silex/Application.php
.. _`Application`: https://github.com/silexphp/Silex/blob/master/src/Silex/Application.php
1 change: 1 addition & 0 deletions reference/constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Validation Constraints Reference
constraints/Currency
constraints/Luhn
constraints/Iban
constraints/Bic
constraints/Isbn
constraints/Issn

Expand Down
98 changes: 98 additions & 0 deletions reference/constraints/Bic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
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: ~
.. 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" />
</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());
}
}
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
1 change: 1 addition & 0 deletions reference/constraints/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ File Constraints
Financial and other Number Constraints
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* :doc:`Bic </reference/constraints/Bic>`
* :doc:`CardScheme </reference/constraints/CardScheme>`
* :doc:`Currency </reference/constraints/Currency>`
* :doc:`Luhn </reference/constraints/Luhn>`
Expand Down

0 comments on commit b13593e

Please sign in to comment.