@@ -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
}
@@ -112,7 +112,7 @@ You can use custom validators like the ones provided by Symfony itself:
112
112
// src/Entity/AcmeEntity.php
113
113
namespace App\Entity;
114
114
115
- use App\Validator\Constraints as AcmeAssert;
115
+ use App\Validator as AcmeAssert;
116
116
use Symfony\Component\Validator\Constraints as Assert;
117
117
118
118
class AcmeEntity
@@ -135,7 +135,7 @@ You can use custom validators like the ones provided by Symfony itself:
135
135
properties :
136
136
name :
137
137
- NotBlank : ~
138
- - App\Validator\Constraints\ ContainsAlphanumeric : ~
138
+ - App\Validator\ContainsAlphanumeric : ~
139
139
140
140
.. code-block :: xml
141
141
@@ -148,7 +148,7 @@ You can use custom validators like the ones provided by Symfony itself:
148
148
<class name =" App\Entity\AcmeEntity" >
149
149
<property name =" name" >
150
150
<constraint name =" NotBlank" />
151
- <constraint name =" App\Validator\Constraints\ ContainsAlphanumeric" />
151
+ <constraint name =" App\Validator\ContainsAlphanumeric" />
152
152
</property >
153
153
</class >
154
154
</constraint-mapping >
@@ -158,7 +158,7 @@ You can use custom validators like the ones provided by Symfony itself:
158
158
// src/Entity/AcmeEntity.php
159
159
namespace App\Entity;
160
160
161
- use App\Validator\Constraints\ ContainsAlphanumeric;
161
+ use App\Validator\ContainsAlphanumeric;
162
162
use Symfony\Component\Validator\Constraints\NotBlank;
163
163
use Symfony\Component\Validator\Mapping\ClassMetadata;
164
164
@@ -246,21 +246,21 @@ not to the property:
246
246
# config/validator/validation.yaml
247
247
App\Entity\AcmeEntity :
248
248
constraints :
249
- - App\Validator\Constraints\ ProtocolClass : ~
249
+ - App\Validator\ProtocolClass : ~
250
250
251
251
.. code-block :: xml
252
252
253
253
<!-- config/validator/validation.xml -->
254
254
<class name =" App\Entity\AcmeEntity" >
255
- <constraint name =" App\Validator\Constraints\ ProtocolClass" />
255
+ <constraint name =" App\Validator\ProtocolClass" />
256
256
</class >
257
257
258
258
.. code-block :: php
259
259
260
260
// src/Entity/AcmeEntity.php
261
261
namespace App\Entity;
262
262
263
- use App\Validator\Constraints\ ProtocolClass;
263
+ use App\Validator\ProtocolClass;
264
264
use Symfony\Component\Validator\Mapping\ClassMetadata;
265
265
266
266
class AcmeEntity
0 commit comments