@@ -125,15 +125,15 @@ that a date must be today or in the past like this:
125
125
/**
126
126
* @Assert\LessThanOrEqual("today")
127
127
*/
128
- protected $age ;
128
+ protected $dateOfBirth ;
129
129
}
130
130
131
131
.. code-block :: yaml
132
132
133
133
# src/AppBundle/Resources/config/validation.yml
134
134
AppBundle\Entity\Person :
135
135
properties :
136
- age :
136
+ dateOfBirth :
137
137
- LessThanOrEqual : today
138
138
139
139
.. code-block :: xml
@@ -145,7 +145,7 @@ that a date must be today or in the past like this:
145
145
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
146
146
147
147
<class name =" AppBundle\Entity\Person" >
148
- <property name =" age " >
148
+ <property name =" dateOfBirth " >
149
149
<constraint name =" LessThanOrEqual" >today</constraint >
150
150
</property >
151
151
</class >
@@ -163,7 +163,7 @@ that a date must be today or in the past like this:
163
163
{
164
164
public static function loadValidatorMetadata(ClassMetadata $metadata)
165
165
{
166
- $metadata->addPropertyConstraint('age ', new Assert\LessThanOrEqual('today'));
166
+ $metadata->addPropertyConstraint('dateOfBirth ', new Assert\LessThanOrEqual('today'));
167
167
}
168
168
}
169
169
@@ -184,15 +184,15 @@ dates. If you want to fix the timezone, append it to the date string:
184
184
/**
185
185
* @Assert\LessThanOrEqual("today UTC")
186
186
*/
187
- protected $age ;
187
+ protected $dateOfBirth ;
188
188
}
189
189
190
190
.. code-block :: yaml
191
191
192
192
# src/AppBundle/Resources/config/validation.yml
193
193
AppBundle\Entity\Person :
194
194
properties :
195
- age :
195
+ dateOfBirth :
196
196
- LessThanOrEqual : today UTC
197
197
198
198
.. code-block :: xml
@@ -204,7 +204,7 @@ dates. If you want to fix the timezone, append it to the date string:
204
204
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
205
205
206
206
<class name =" AppBundle\Entity\Person" >
207
- <property name =" age " >
207
+ <property name =" dateOfBirth " >
208
208
<constraint name =" LessThanOrEqual" >today UTC</constraint >
209
209
</property >
210
210
</class >
@@ -222,7 +222,7 @@ dates. If you want to fix the timezone, append it to the date string:
222
222
{
223
223
public static function loadValidatorMetadata(ClassMetadata $metadata)
224
224
{
225
- $metadata->addPropertyConstraint('age ', new Assert\LessThanOrEqual('today UTC'));
225
+ $metadata->addPropertyConstraint('dateOfBirth ', new Assert\LessThanOrEqual('today UTC'));
226
226
}
227
227
}
228
228
@@ -243,15 +243,15 @@ can check that a person must be at least 18 years old like this:
243
243
/**
244
244
* @Assert\LessThanOrEqual("-18 years")
245
245
*/
246
- protected $age ;
246
+ protected $dateOfBirth ;
247
247
}
248
248
249
249
.. code-block :: yaml
250
250
251
251
# src/AppBundle/Resources/config/validation.yml
252
252
AppBundle\Entity\Person :
253
253
properties :
254
- age :
254
+ dateOfBirth :
255
255
- LessThanOrEqual : -18 years
256
256
257
257
.. code-block :: xml
@@ -263,7 +263,7 @@ can check that a person must be at least 18 years old like this:
263
263
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
264
264
265
265
<class name =" AppBundle\Entity\Person" >
266
- <property name =" age " >
266
+ <property name =" dateOfBirth " >
267
267
<constraint name =" LessThanOrEqual" >-18 years</constraint >
268
268
</property >
269
269
</class >
@@ -281,7 +281,7 @@ can check that a person must be at least 18 years old like this:
281
281
{
282
282
public static function loadValidatorMetadata(ClassMetadata $metadata)
283
283
{
284
- $metadata->addPropertyConstraint('age ', new Assert\LessThanOrEqual('-18 years'));
284
+ $metadata->addPropertyConstraint('dateOfBirth ', new Assert\LessThanOrEqual('-18 years'));
285
285
}
286
286
}
287
287
0 commit comments