@@ -14,8 +14,8 @@ Creating the Constraint Class
1414
1515First you need to create a Constraint class and extend :class: `Symfony\\ Component\\ Validator\\ Constraint `::
1616
17- // src/Validator/Constraints/ ContainsAlphanumeric.php
18- namespace App\Validator\Constraints ;
17+ // src/Validator/ContainsAlphanumeric.php
18+ namespace App\Validator;
1919
2020 use Symfony\Component\Validator\Constraint;
2121
@@ -54,8 +54,8 @@ when actually performing the validation.
5454
5555The validator class only has one required method ``validate() ``::
5656
57- // src/Validator/Constraints/ ContainsAlphanumericValidator.php
58- namespace App\Validator\Constraints ;
57+ // src/Validator/ContainsAlphanumericValidator.php
58+ namespace App\Validator;
5959
6060 use Symfony\Component\Validator\Constraint;
6161 use Symfony\Component\Validator\ConstraintValidator;
@@ -71,7 +71,7 @@ The validator class only has one required method ``validate()``::
7171 }
7272
7373 // custom constraints should ignore null and empty values to allow
74- // other constraints (NotBlank, NotNull, etc.) take care of that
74+ // other constraints (NotBlank, NotNull, etc.) to take care of that
7575 if (null === $value || '' === $value) {
7676 return;
7777 }
@@ -117,7 +117,7 @@ You can use custom validators like the ones provided by Symfony itself:
117117 // src/Entity/AcmeEntity.php
118118 namespace App\Entity;
119119
120- use App\Validator\Constraints as AcmeAssert;
120+ use App\Validator as AcmeAssert;
121121 use Symfony\Component\Validator\Constraints as Assert;
122122
123123 class AcmeEntity
@@ -140,7 +140,7 @@ You can use custom validators like the ones provided by Symfony itself:
140140 properties :
141141 name :
142142 - NotBlank : ~
143- - App\Validator\Constraints\ ContainsAlphanumeric : ~
143+ - App\Validator\ContainsAlphanumeric : ~
144144
145145 .. code-block :: xml
146146
@@ -153,7 +153,7 @@ You can use custom validators like the ones provided by Symfony itself:
153153 <class name =" App\Entity\AcmeEntity" >
154154 <property name =" name" >
155155 <constraint name =" NotBlank" />
156- <constraint name =" App\Validator\Constraints\ ContainsAlphanumeric" />
156+ <constraint name =" App\Validator\ContainsAlphanumeric" />
157157 </property >
158158 </class >
159159 </constraint-mapping >
@@ -163,7 +163,7 @@ You can use custom validators like the ones provided by Symfony itself:
163163 // src/Entity/AcmeEntity.php
164164 namespace App\Entity;
165165
166- use App\Validator\Constraints\ ContainsAlphanumeric;
166+ use App\Validator\ContainsAlphanumeric;
167167 use Symfony\Component\Validator\Constraints\NotBlank;
168168 use Symfony\Component\Validator\Mapping\ClassMetadata;
169169
@@ -241,21 +241,21 @@ not to the property:
241241 # config/validator/validation.yaml
242242 App\Entity\AcmeEntity :
243243 constraints :
244- - App\Validator\Constraints\ ProtocolClass : ~
244+ - App\Validator\ProtocolClass : ~
245245
246246 .. code-block :: xml
247247
248248 <!-- config/validator/validation.xml -->
249249 <class name =" App\Entity\AcmeEntity" >
250- <constraint name =" App\Validator\Constraints\ ProtocolClass" />
250+ <constraint name =" App\Validator\ProtocolClass" />
251251 </class >
252252
253253 .. code-block :: php
254254
255255 // src/Entity/AcmeEntity.php
256256 namespace App\Entity;
257257
258- use App\Validator\Constraints\ ProtocolClass;
258+ use App\Validator\ProtocolClass;
259259 use Symfony\Component\Validator\Mapping\ClassMetadata;
260260
261261 class AcmeEntity
0 commit comments