@@ -122,15 +122,15 @@ that a date must be today or in the past like this:
122
122
/**
123
123
* @Assert\LessThanOrEqual("today")
124
124
*/
125
- protected $age ;
125
+ protected $dateOfBirth ;
126
126
}
127
127
128
128
.. code-block :: yaml
129
129
130
130
# config/validator/validation.yaml
131
131
App\Entity\Person :
132
132
properties :
133
- age :
133
+ dateOfBirth :
134
134
- LessThanOrEqual : today
135
135
136
136
.. code-block :: xml
@@ -142,7 +142,7 @@ that a date must be today or in the past like this:
142
142
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
143
143
144
144
<class name =" App\Entity\Person" >
145
- <property name =" age " >
145
+ <property name =" dateOfBirth " >
146
146
<constraint name =" LessThanOrEqual" >today</constraint >
147
147
</property >
148
148
</class >
@@ -160,7 +160,7 @@ that a date must be today or in the past like this:
160
160
{
161
161
public static function loadValidatorMetadata(ClassMetadata $metadata)
162
162
{
163
- $metadata->addPropertyConstraint('age ', new Assert\LessThanOrEqual('today'));
163
+ $metadata->addPropertyConstraint('dateOfBirth ', new Assert\LessThanOrEqual('today'));
164
164
}
165
165
}
166
166
@@ -181,15 +181,15 @@ dates. If you want to fix the timezone, append it to the date string:
181
181
/**
182
182
* @Assert\LessThanOrEqual("today UTC")
183
183
*/
184
- protected $age ;
184
+ protected $dateOfBirth ;
185
185
}
186
186
187
187
.. code-block :: yaml
188
188
189
189
# config/validator/validation.yaml
190
190
App\Entity\Person :
191
191
properties :
192
- age :
192
+ dateOfBirth :
193
193
- LessThanOrEqual : today UTC
194
194
195
195
.. code-block :: xml
@@ -201,7 +201,7 @@ dates. If you want to fix the timezone, append it to the date string:
201
201
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
202
202
203
203
<class name =" App\Entity\Person" >
204
- <property name =" age " >
204
+ <property name =" dateOfBirth " >
205
205
<constraint name =" LessThanOrEqual" >today UTC</constraint >
206
206
</property >
207
207
</class >
@@ -219,7 +219,7 @@ dates. If you want to fix the timezone, append it to the date string:
219
219
{
220
220
public static function loadValidatorMetadata(ClassMetadata $metadata)
221
221
{
222
- $metadata->addPropertyConstraint('age ', new Assert\LessThanOrEqual('today UTC'));
222
+ $metadata->addPropertyConstraint('dateOfBirth ', new Assert\LessThanOrEqual('today UTC'));
223
223
}
224
224
}
225
225
@@ -240,15 +240,15 @@ can check that a person must be at least 18 years old like this:
240
240
/**
241
241
* @Assert\LessThanOrEqual("-18 years")
242
242
*/
243
- protected $age ;
243
+ protected $dateOfBirth ;
244
244
}
245
245
246
246
.. code-block :: yaml
247
247
248
248
# config/validator/validation.yaml
249
249
App\Entity\Person :
250
250
properties :
251
- age :
251
+ dateOfBirth :
252
252
- LessThanOrEqual : -18 years
253
253
254
254
.. code-block :: xml
@@ -260,7 +260,7 @@ can check that a person must be at least 18 years old like this:
260
260
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
261
261
262
262
<class name =" App\Entity\Person" >
263
- <property name =" age " >
263
+ <property name =" dateOfBirth " >
264
264
<constraint name =" LessThanOrEqual" >-18 years</constraint >
265
265
</property >
266
266
</class >
@@ -278,7 +278,7 @@ can check that a person must be at least 18 years old like this:
278
278
{
279
279
public static function loadValidatorMetadata(ClassMetadata $metadata)
280
280
{
281
- $metadata->addPropertyConstraint('age ', new Assert\LessThanOrEqual('-18 years'));
281
+ $metadata->addPropertyConstraint('dateOfBirth ', new Assert\LessThanOrEqual('-18 years'));
282
282
}
283
283
}
284
284
0 commit comments