@@ -14,8 +14,8 @@ Creating the 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/Validator/Constraints/ ContainsAlphanumeric.php
18
- namespace App\Validator\Constraints ;
17
+ // src/Validator/ContainsAlphanumeric.php
18
+ namespace App\Validator;
19
19
20
20
use Symfony\Component\Validator\Constraint;
21
21
@@ -54,8 +54,8 @@ when actually performing the validation.
54
54
55
55
The validator class only has one required method ``validate() ``::
56
56
57
- // src/Validator/Constraints/ ContainsAlphanumericValidator.php
58
- namespace App\Validator\Constraints ;
57
+ // src/Validator/ContainsAlphanumericValidator.php
58
+ namespace App\Validator;
59
59
60
60
use Symfony\Component\Validator\Constraint;
61
61
use Symfony\Component\Validator\ConstraintValidator;
@@ -71,7 +71,7 @@ The validator class only has one required method ``validate()``::
71
71
}
72
72
73
73
// 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
75
75
if (null === $value || '' === $value) {
76
76
return;
77
77
}
@@ -117,7 +117,7 @@ You can use custom validators like the ones provided by Symfony itself:
117
117
// src/Entity/AcmeEntity.php
118
118
namespace App\Entity;
119
119
120
- use App\Validator\Constraints as AcmeAssert;
120
+ use App\Validator as AcmeAssert;
121
121
use Symfony\Component\Validator\Constraints as Assert;
122
122
123
123
class AcmeEntity
@@ -140,7 +140,7 @@ You can use custom validators like the ones provided by Symfony itself:
140
140
properties :
141
141
name :
142
142
- NotBlank : ~
143
- - App\Validator\Constraints\ ContainsAlphanumeric : ~
143
+ - App\Validator\ContainsAlphanumeric : ~
144
144
145
145
.. code-block :: xml
146
146
@@ -153,7 +153,7 @@ You can use custom validators like the ones provided by Symfony itself:
153
153
<class name =" App\Entity\AcmeEntity" >
154
154
<property name =" name" >
155
155
<constraint name =" NotBlank" />
156
- <constraint name =" App\Validator\Constraints\ ContainsAlphanumeric" />
156
+ <constraint name =" App\Validator\ContainsAlphanumeric" />
157
157
</property >
158
158
</class >
159
159
</constraint-mapping >
@@ -163,7 +163,7 @@ You can use custom validators like the ones provided by Symfony itself:
163
163
// src/Entity/AcmeEntity.php
164
164
namespace App\Entity;
165
165
166
- use App\Validator\Constraints\ ContainsAlphanumeric;
166
+ use App\Validator\ContainsAlphanumeric;
167
167
use Symfony\Component\Validator\Constraints\NotBlank;
168
168
use Symfony\Component\Validator\Mapping\ClassMetadata;
169
169
@@ -241,21 +241,21 @@ not to the property:
241
241
# config/validator/validation.yaml
242
242
App\Entity\AcmeEntity :
243
243
constraints :
244
- - App\Validator\Constraints\ ProtocolClass : ~
244
+ - App\Validator\ProtocolClass : ~
245
245
246
246
.. code-block :: xml
247
247
248
248
<!-- config/validator/validation.xml -->
249
249
<class name =" App\Entity\AcmeEntity" >
250
- <constraint name =" App\Validator\Constraints\ ProtocolClass" />
250
+ <constraint name =" App\Validator\ProtocolClass" />
251
251
</class >
252
252
253
253
.. code-block :: php
254
254
255
255
// src/Entity/AcmeEntity.php
256
256
namespace App\Entity;
257
257
258
- use App\Validator\Constraints\ ProtocolClass;
258
+ use App\Validator\ProtocolClass;
259
259
use Symfony\Component\Validator\Mapping\ClassMetadata;
260
260
261
261
class AcmeEntity
0 commit comments