-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Changes from 1 commit
238e201
8b04d1b
6726882
51126fa
b69f48d
f952885
8ca96a4
0543699
6bbfaf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
`Business Identifier Code (BIC)`. BIC is an internationally agreed means to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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>` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: php-annotations | ||
|
||
// src/Acme/SubscriptionBundle/Entity/Transaction.php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use |
||
namespace Acme\SubscriptionBundle\Entity; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "[...] BIC check" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
.. include:: /reference/constraints/_payload-option.rst.inc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: any idea @javiereguiluz... confused... 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you guys 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] of a [...]