Skip to content
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

[Validator] added BIC validator #5623

Closed
wants to merge 9 commits into from
107 changes: 107 additions & 0 deletions reference/constraints/Bic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
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 an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] of a [...]

`Business Identifier Code (BIC)`. BIC is an internationally agreed means to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the closing ``` needs to be followed by an underscore: ``Business Identifier Code (BIC)_

uniquely identify both financial and non-financiel institutions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-financiel -> non-financial

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're absolutely right!


+----------------+-----------------------------------------------------------------------+
| Applies to | :ref:`property or method<validation-property-target>` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a space before the opening angle bracket.

+----------------+-----------------------------------------------------------------------+
| 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will contain a Business Identifier Code (BIC).


.. configuration-block::

.. code-block:: php-annotations

// src/Acme/SubscriptionBundle/Entity/Transaction.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use src/AppBundle/Entity/Transaction.php (this probably is inconsistent with the other articles, but they need to be updated)

namespace Acme\SubscriptionBundle\Entity;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would of course mean that you have to change this as well (as well as the XML, Yaml and PHP code examples)


use Symfony\Component\Validator\Constraints as Assert;

class Transaction
{
/**
* @Assert\Bic(
* message="This is not a valid Business Identifier Code (BIC)."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can omit the message (it's already the default message by the way).

* )
*/
protected $businessIdentifierCode;
}

.. code-block:: yaml

# src/Acme/SubscriptionBundle/Resources/config/validation.yml
Acme\SubscriptionBundle\Entity\Transaction:
properties:
businessIdentifierCode:
- Bic:
message: This is not a valid Business Identifier Code (BIC).

.. code-block:: xml

<!-- src/Acme/SubscriptionBundle/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="Acme\SubscriptionBundle\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/Acme/SubscriptionBundle/Entity/Transaction.php
namespace Acme\SubscriptionBundle\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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"[...] BIC check" ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


.. include:: /reference/constraints/_payload-option.rst.inc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure why, but this part is not in the 2.8 branch:
https://github.com/symfony/symfony-docs/blob/2.8/reference/constraints/Iban.rst

any idea @javiereguiluz... confused... 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Upwards branch merging" is done from time to time in a non-formal schedule. Sometimes 2.8 and master are behind the other branchs, but at the end our doc managers always merge upwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you guys 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OskarStark don't rely on GitHub's reStructuredText rendering. It doesn't support lots of the things that we use.


.. _`Business Identifier Code (BIC)`: https://en.wikipedia.org/wiki/Business_Identifier_Code