@@ -57,13 +57,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
57
57
.. code-block :: xml
58
58
59
59
<!-- src/Acme/SocialBundle/Resources/config/validation.xml -->
60
- <class name =" Acme\SocialBundle\Entity\Person" >
61
- <property name =" age" >
62
- <constraint name =" GreaterThan" >
63
- <option name =" value" >18</option >
64
- </constraint >
65
- </property >
66
- </class >
60
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
61
+ <constraint-mapping xmlns =" http://symfony.com/schema/dic/constraint-mapping"
62
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
63
+ xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
64
+
65
+ <class name =" Acme\SocialBundle\Entity\Person" >
66
+ <property name =" age" >
67
+ <constraint name =" GreaterThan" >
68
+ <option name =" value" >18</option >
69
+ </constraint >
70
+ </property >
71
+ </class >
72
+ </constraint-mapping >
67
73
68
74
.. code-block :: php
69
75
@@ -86,6 +92,9 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
86
92
Comparing Dates
87
93
---------------
88
94
95
+ .. versionadded :: 2.6
96
+ The feature to compare dates was added in Symfony 2.6.
97
+
89
98
This constraint can be used to compare ``DateTime `` objects against any date
90
99
string `accepted by the DateTime constructor `_. For example, you could check
91
100
that a date must at least be the next day:
@@ -94,15 +103,15 @@ that a date must at least be the next day:
94
103
95
104
.. code-block :: yaml
96
105
97
- # src/OrderBundle/Resources/config/validation.yml
106
+ # src/Acme/ OrderBundle/Resources/config/validation.yml
98
107
Acme\OrderBundle\Entity\Order :
99
108
properties :
100
109
deliveryDate :
101
110
- GreaterThan : today
102
111
103
112
.. code-block :: php-annotations
104
113
105
- // src/Acme/SocialBundle /Entity/Order.php
114
+ // src/Acme/OrderBundle /Entity/Order.php
106
115
namespace Acme\OrderBundle\Entity;
107
116
108
117
use Symfony\Component\Validator\Constraints as Assert;
@@ -118,11 +127,17 @@ that a date must at least be the next day:
118
127
.. code-block :: xml
119
128
120
129
<!-- src/Acme/OrderBundle/Resources/config/validation.xml -->
121
- <class name =" Acme\OrderBundle\Entity\Order" >
122
- <property name =" deliveryDate" >
123
- <constraint name =" GreaterThan" >today</constraint >
124
- </property >
125
- </class >
130
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
131
+ <constraint-mapping xmlns =" http://symfony.com/schema/dic/constraint-mapping"
132
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
133
+ xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
134
+
135
+ <class name =" Acme\OrderBundle\Entity\Order" >
136
+ <property name =" deliveryDate" >
137
+ <constraint name =" GreaterThan" >today</constraint >
138
+ </property >
139
+ </class >
140
+ </constraint-mapping >
126
141
127
142
.. code-block :: php
128
143
@@ -147,15 +162,15 @@ dates. If you want to fix the timezone, append it to the date string:
147
162
148
163
.. code-block :: yaml
149
164
150
- # src/OrderBundle/Resources/config/validation.yml
165
+ # src/Acme/ OrderBundle/Resources/config/validation.yml
151
166
Acme\OrderBundle\Entity\Order :
152
167
properties :
153
168
deliveryDate :
154
169
- GreaterThan : today UTC
155
170
156
171
.. code-block :: php-annotations
157
172
158
- // src/Acme/SocialBundle /Entity/Order.php
173
+ // src/Acme/OrderBundle /Entity/Order.php
159
174
namespace Acme\OrderBundle\Entity;
160
175
161
176
use Symfony\Component\Validator\Constraints as Assert;
@@ -171,11 +186,17 @@ dates. If you want to fix the timezone, append it to the date string:
171
186
.. code-block :: xml
172
187
173
188
<!-- src/Acme/OrderBundle/Resources/config/validation.xml -->
174
- <class name =" Acme\OrderBundle\Entity\Order" >
175
- <property name =" deliveryDate" >
176
- <constraint name =" GreaterThan" >today UTC</constraint >
177
- </property >
178
- </class >
189
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
190
+ <constraint-mapping xmlns =" http://symfony.com/schema/dic/constraint-mapping"
191
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
192
+ xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
193
+
194
+ <class name =" Acme\OrderBundle\Entity\Order" >
195
+ <property name =" deliveryDate" >
196
+ <constraint name =" GreaterThan" >today UTC</constraint >
197
+ </property >
198
+ </class >
199
+ </constraint-mapping >
179
200
180
201
.. code-block :: php
181
202
@@ -201,15 +222,15 @@ current time:
201
222
202
223
.. code-block :: yaml
203
224
204
- # src/OrderBundle/Resources/config/validation.yml
225
+ # src/Acme/ OrderBundle/Resources/config/validation.yml
205
226
Acme\OrderBundle\Entity\Order :
206
227
properties :
207
228
deliveryDate :
208
229
- GreaterThan : +5 hours
209
230
210
231
.. code-block :: php-annotations
211
232
212
- // src/Acme/SocialBundle /Entity/Order.php
233
+ // src/Acme/OrderBundle /Entity/Order.php
213
234
namespace Acme\OrderBundle\Entity;
214
235
215
236
use Symfony\Component\Validator\Constraints as Assert;
@@ -225,11 +246,17 @@ current time:
225
246
.. code-block :: xml
226
247
227
248
<!-- src/Acme/OrderBundle/Resources/config/validation.xml -->
228
- <class name =" Acme\OrderBundle\Entity\Order" >
229
- <property name =" deliveryDate" >
230
- <constraint name =" GreaterThan" >+5 hours</constraint >
231
- </property >
232
- </class >
249
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
250
+ <constraint-mapping xmlns =" http://symfony.com/schema/dic/constraint-mapping"
251
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
252
+ xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
253
+
254
+ <class name =" Acme\OrderBundle\Entity\Order" >
255
+ <property name =" deliveryDate" >
256
+ <constraint name =" GreaterThan" >+5 hours</constraint >
257
+ </property >
258
+ </class >
259
+ </constraint-mapping >
233
260
234
261
.. code-block :: php
235
262
0 commit comments