Skip to content

Commit de6db8f

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: [Validator] Deprecate implicit constraint option names in YAML/XML mapping files
2 parents 142b8c9 + c624186 commit de6db8f

26 files changed

+141
-71
lines changed

forms.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ object.
495495
- NotBlank: ~
496496
dueDate:
497497
- NotBlank: ~
498-
- Type: \DateTimeInterface
498+
- Type:
499+
type: \DateTimeInterface
499500
500501
.. code-block:: xml
501502
@@ -512,7 +513,9 @@ object.
512513
</property>
513514
<property name="dueDate">
514515
<constraint name="NotBlank"/>
515-
<constraint name="Type">\DateTimeInterface</constraint>
516+
<constraint name="Type">
517+
<option name="type">\DateTimeInterface</option>
518+
</constraint>
516519
</property>
517520
</class>
518521
</constraint-mapping>

reference/constraints/All.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ entry in that array:
4141
properties:
4242
favoriteColors:
4343
- All:
44-
- NotBlank: ~
45-
- Length:
46-
min: 5
44+
constraints:
45+
- NotBlank: ~
46+
- Length:
47+
min: 5
4748
4849
.. code-block:: xml
4950

reference/constraints/AtLeastOneOf.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ The following constraints ensure that:
5353
properties:
5454
password:
5555
- AtLeastOneOf:
56-
- Regex: '/#/'
56+
- Regex:
57+
pattern: '/#/'
5758
- Length:
5859
min: 10
5960
grades:
6061
- AtLeastOneOf:
6162
- Count:
6263
min: 3
6364
- All:
64-
- GreaterThanOrEqual: 5
65+
constraints:
66+
- GreaterThanOrEqual:
67+
value: 5
6568
6669
.. code-block:: xml
6770
@@ -93,7 +96,7 @@ The following constraints ensure that:
9396
<constraint name="All">
9497
<option name="constraints">
9598
<constraint name="GreaterThanOrEqual">
96-
5
99+
<option name="value">5</option>
97100
</constraint>
98101
</option>
99102
</constraint>

reference/constraints/Callback.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Configuration
5050
# config/validator/validation.yaml
5151
App\Entity\Author:
5252
constraints:
53-
- Callback: validate
53+
- Callback:
54+
callback: validate
5455
5556
.. code-block:: xml
5657
@@ -61,7 +62,9 @@ Configuration
6162
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6263
6364
<class name="App\Entity\Author">
64-
<constraint name="Callback">validate</constraint>
65+
<constraint name="Callback">
66+
<option name="callback">validate</option>
67+
</constraint>
6568
</class>
6669
</constraint-mapping>
6770
@@ -177,7 +180,8 @@ You can then use the following configuration to invoke this validator:
177180
# config/validator/validation.yaml
178181
App\Entity\Author:
179182
constraints:
180-
- Callback: [Acme\Validator, validate]
183+
- Callback:
184+
callback: [Acme\Validator, validate]
181185
182186
.. code-block:: xml
183187
@@ -189,8 +193,10 @@ You can then use the following configuration to invoke this validator:
189193
190194
<class name="App\Entity\Author">
191195
<constraint name="Callback">
192-
<value>Acme\Validator</value>
193-
<value>validate</value>
196+
<option name="callback">
197+
<value>Acme\Validator</value>
198+
<value>validate</value>
199+
</option>
194200
</constraint>
195201
</class>
196202
</constraint-mapping>

reference/constraints/Charset.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class uses UTF-8, you could do the following:
3737
App\Entity\FileDTO:
3838
properties:
3939
content:
40-
- Charset: 'UTF-8'
40+
- Charset:
41+
charset: 'UTF-8'
4142
4243
.. code-block:: xml
4344

reference/constraints/DivisibleBy.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ The following constraints ensure that:
4949
App\Entity\Item:
5050
properties:
5151
weight:
52-
- DivisibleBy: 0.25
52+
- DivisibleBy:
53+
value: 0.25
5354
quantity:
5455
- DivisibleBy:
5556
value: 5
@@ -65,7 +66,7 @@ The following constraints ensure that:
6566
<class name="App\Entity\Item">
6667
<property name="weight">
6768
<constraint name="DivisibleBy">
68-
<value>0.25</value>
69+
<option name="value">0.25</option>
6970
</constraint>
7071
</property>
7172
<property name="quantity">

reference/constraints/EqualTo.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ and that the ``age`` is ``20``, you could do the following:
4848
App\Entity\Person:
4949
properties:
5050
firstName:
51-
- EqualTo: Mary
51+
- EqualTo:
52+
value: Mary
5253
age:
5354
- EqualTo:
5455
value: 20
@@ -64,7 +65,7 @@ and that the ``age`` is ``20``, you could do the following:
6465
<class name="App\Entity\Person">
6566
<property name="firstName">
6667
<constraint name="EqualTo">
67-
Mary
68+
<option name="value">Mary</option>
6869
</constraint>
6970
</property>
7071
<property name="age">

reference/constraints/GreaterThan.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ The following constraints ensure that:
4646
App\Entity\Person:
4747
properties:
4848
siblings:
49-
- GreaterThan: 5
49+
- GreaterThan:
50+
value: 5
5051
age:
5152
- GreaterThan:
5253
value: 18
@@ -62,7 +63,7 @@ The following constraints ensure that:
6263
<class name="App\Entity\Person">
6364
<property name="siblings">
6465
<constraint name="GreaterThan">
65-
5
66+
<option name="value">5</option>
6667
</constraint>
6768
</property>
6869
<property name="age">
@@ -182,7 +183,8 @@ dates. If you want to fix the timezone, append it to the date string:
182183
App\Entity\Order:
183184
properties:
184185
deliveryDate:
185-
- GreaterThan: today UTC
186+
- GreaterThan:
187+
value: today UTC
186188
187189
.. code-block:: xml
188190
@@ -194,7 +196,9 @@ dates. If you want to fix the timezone, append it to the date string:
194196
195197
<class name="App\Entity\Order">
196198
<property name="deliveryDate">
197-
<constraint name="GreaterThan">today UTC</constraint>
199+
<constraint name="GreaterThan">
200+
<option name="value">today UTC</option>
201+
</constraint>
198202
</property>
199203
</class>
200204
</constraint-mapping>
@@ -242,7 +246,8 @@ current time:
242246
App\Entity\Order:
243247
properties:
244248
deliveryDate:
245-
- GreaterThan: +5 hours
249+
- GreaterThan:
250+
value: +5 hours
246251
247252
.. code-block:: xml
248253
@@ -254,7 +259,9 @@ current time:
254259
255260
<class name="App\Entity\Order">
256261
<property name="deliveryDate">
257-
<constraint name="GreaterThan">+5 hours</constraint>
262+
<constraint name="GreaterThan">
263+
<option name="value">+5 hours</option>
264+
</constraint>
258265
</property>
259266
</class>
260267
</constraint-mapping>

reference/constraints/GreaterThanOrEqual.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ The following constraints ensure that:
4545
App\Entity\Person:
4646
properties:
4747
siblings:
48-
- GreaterThanOrEqual: 5
48+
- GreaterThanOrEqual:
49+
value: 5
4950
age:
5051
- GreaterThanOrEqual:
5152
value: 18
@@ -61,7 +62,7 @@ The following constraints ensure that:
6162
<class name="App\Entity\Person">
6263
<property name="siblings">
6364
<constraint name="GreaterThanOrEqual">
64-
5
65+
<option name="value">5</option>
6566
</constraint>
6667
</property>
6768
<property name="age">
@@ -122,7 +123,8 @@ that a date must at least be the current day:
122123
App\Entity\Order:
123124
properties:
124125
deliveryDate:
125-
- GreaterThanOrEqual: today
126+
- GreaterThanOrEqual:
127+
value: today
126128
127129
.. code-block:: xml
128130
@@ -134,7 +136,9 @@ that a date must at least be the current day:
134136
135137
<class name="App\Entity\Order">
136138
<property name="deliveryDate">
137-
<constraint name="GreaterThanOrEqual">today</constraint>
139+
<constraint name="GreaterThanOrEqual">
140+
<option name="value">today</option>
141+
</constraint>
138142
</property>
139143
</class>
140144
</constraint-mapping>
@@ -181,7 +185,8 @@ dates. If you want to fix the timezone, append it to the date string:
181185
App\Entity\Order:
182186
properties:
183187
deliveryDate:
184-
- GreaterThanOrEqual: today UTC
188+
- GreaterThanOrEqual:
189+
value: today UTC
185190
186191
.. code-block:: xml
187192
@@ -193,7 +198,9 @@ dates. If you want to fix the timezone, append it to the date string:
193198
194199
<class name="App\Entity\Order">
195200
<property name="deliveryDate">
196-
<constraint name="GreaterThanOrEqual">today UTC</constraint>
201+
<constraint name="GreaterThanOrEqual">
202+
<option name="value">today UTC</option>
203+
</constraint>
197204
</property>
198205
</class>
199206
</constraint-mapping>
@@ -241,7 +248,8 @@ current time:
241248
App\Entity\Order:
242249
properties:
243250
deliveryDate:
244-
- GreaterThanOrEqual: +5 hours
251+
- GreaterThanOrEqual:
252+
value: +5 hours
245253
246254
.. code-block:: xml
247255
@@ -253,7 +261,9 @@ current time:
253261
254262
<class name="App\Entity\Order">
255263
<property name="deliveryDate">
256-
<constraint name="GreaterThanOrEqual">+5 hours</constraint>
264+
<constraint name="GreaterThanOrEqual">
265+
<option name="value">+5 hours</option>
266+
</constraint>
257267
</property>
258268
</class>
259269
</constraint-mapping>

reference/constraints/IdenticalTo.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ The following constraints ensure that:
5151
App\Entity\Person:
5252
properties:
5353
firstName:
54-
- IdenticalTo: Mary
54+
- IdenticalTo:
55+
value: Mary
5556
age:
5657
- IdenticalTo:
5758
value: 20
@@ -67,7 +68,7 @@ The following constraints ensure that:
6768
<class name="App\Entity\Person">
6869
<property name="firstName">
6970
<constraint name="IdenticalTo">
70-
Mary
71+
<option name="value">Mary</option>
7172
</constraint>
7273
</property>
7374
<property name="age">

0 commit comments

Comments
 (0)