Skip to content

Commit 46fb58b

Browse files
committed
Fixed code examples in cookbook/validation
1 parent 1d0fe96 commit 46fb58b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cookbook/validation/custom_constraint.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Creating Constraint class
1414

1515
First you need to create a Constraint class and extend :class:`Symfony\\Component\\Validator\\Constraint`::
1616

17+
// src/Acme/DemoBundle/Validator/constraints/ContainsAlphanumeric.php
1718
namespace Acme\DemoBundle\Validator\Constraints;
1819

1920
use Symfony\Component\Validator\Constraint;
@@ -53,6 +54,7 @@ when actually performing the validation.
5354

5455
The validator class is also simple, and only has one required method: ``isValid``::
5556

57+
// src/Acme/DemoBundle/Validator/Constraints/ContainsAlphanumericValidator.php
5658
namespace Acme\DemoBundle\Validator\Constraints;
5759
5860
use Symfony\Component\Validator\Constraint;
@@ -96,7 +98,6 @@ Using custom validators is very easy, just as the ones provided by Symfony2 itse
9698
.. code-block:: php-annotations
9799
98100
// src/Acme/DemoBundle/Entity/AcmeEntity.php
99-
100101
use Symfony\Component\Validator\Constraints as Assert;
101102
use Acme\DemoBundle\Validator\Constraints as AcmeAssert;
102103
@@ -132,7 +133,6 @@ Using custom validators is very easy, just as the ones provided by Symfony2 itse
132133
.. code-block:: php
133134
134135
// src/Acme/DemoBundle/Entity/AcmeEntity.php
135-
136136
use Symfony\Component\Validator\Mapping\ClassMetadata;
137137
use Symfony\Component\Validator\Constraints\NotBlank;
138138
use Acme\DemoBundle\Validator\Constraints\ContainsAlphanumeric;
@@ -181,8 +181,7 @@ tag and an ``alias`` attribute:
181181
182182
$container
183183
->register('validator.unique.your_validator_name', 'Fully\Qualified\Validator\Class\Name')
184-
->addTag('validator.constraint_validator', array('alias' => 'alias_name'))
185-
;
184+
->addTag('validator.constraint_validator', array('alias' => 'alias_name'));
186185
187186
Your constraint class should now use this alias to reference the appropriate
188187
validator::

0 commit comments

Comments
 (0)