@@ -14,6 +14,7 @@ Creating Constraint class
14
14
15
15
First you need to create a Constraint class and extend :class: `Symfony\\ Component\\ Validator\\ Constraint `::
16
16
17
+ // src/Acme/DemoBundle/Validator/constraints/ContainsAlphanumeric.php
17
18
namespace Acme\D emoBundle\V alidator\C onstraints;
18
19
19
20
use Symfony\C omponent\V alidator\C onstraint;
@@ -53,6 +54,7 @@ when actually performing the validation.
53
54
54
55
The validator class is also simple, and only has one required method: ``isValid ``::
55
56
57
+ // src/Acme/DemoBundle/Validator/Constraints/ContainsAlphanumericValidator.php
56
58
namespace Acme\DemoBundle\Validator\Constraints;
57
59
58
60
use Symfony\Component\Validator\Constraint;
@@ -96,7 +98,6 @@ Using custom validators is very easy, just as the ones provided by Symfony2 itse
96
98
.. code-block :: php-annotations
97
99
98
100
// src/Acme/DemoBundle/Entity/AcmeEntity.php
99
-
100
101
use Symfony\Component\Validator\Constraints as Assert;
101
102
use Acme\DemoBundle\Validator\Constraints as AcmeAssert;
102
103
@@ -132,7 +133,6 @@ Using custom validators is very easy, just as the ones provided by Symfony2 itse
132
133
.. code-block :: php
133
134
134
135
// src/Acme/DemoBundle/Entity/AcmeEntity.php
135
-
136
136
use Symfony\Component\Validator\Mapping\ClassMetadata;
137
137
use Symfony\Component\Validator\Constraints\NotBlank;
138
138
use Acme\DemoBundle\Validator\Constraints\ContainsAlphanumeric;
@@ -181,8 +181,7 @@ tag and an ``alias`` attribute:
181
181
182
182
$container
183
183
->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'));
186
185
187
186
Your constraint class should now use this alias to reference the appropriate
188
187
validator::
0 commit comments