Skip to content

Commit c40b618

Browse files
committed
minor #5065 [Reference] fix code block order (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Reference] fix code block order | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | The new documentation standard for the order of code blocks in validation contraint configurations is *Annotations*, *YAML*, *XML*, *PHP*. This commit fixes the order of the configuration examples. Commits ------- 4592564 fix code block order
2 parents 73ccc8b + 4592564 commit c40b618

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+534
-534
lines changed

book/forms.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,6 @@ object.
344344

345345
.. configuration-block::
346346

347-
.. code-block:: yaml
348-
349-
# AppBundle/Resources/config/validation.yml
350-
AppBundle\Entity\Task:
351-
properties:
352-
task:
353-
- NotBlank: ~
354-
dueDate:
355-
- NotBlank: ~
356-
- Type: \DateTime
357-
358347
.. code-block:: php-annotations
359348
360349
// AppBundle/Entity/Task.php
@@ -374,6 +363,17 @@ object.
374363
protected $dueDate;
375364
}
376365
366+
.. code-block:: yaml
367+
368+
# AppBundle/Resources/config/validation.yml
369+
AppBundle\Entity\Task:
370+
properties:
371+
task:
372+
- NotBlank: ~
373+
dueDate:
374+
- NotBlank: ~
375+
- Type: \DateTime
376+
377377
.. code-block:: xml
378378
379379
<!-- AppBundle/Resources/config/validation.xml -->

cookbook/doctrine/file_uploads.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,6 @@ rules::
152152

153153
.. configuration-block::
154154

155-
.. code-block:: yaml
156-
157-
# src/AppBundle/Resources/config/validation.yml
158-
AppBundle\Entity\Document:
159-
properties:
160-
file:
161-
- File:
162-
maxSize: 6000000
163-
164155
.. code-block:: php-annotations
165156
166157
// src/AppBundle/Entity/Document.php
@@ -179,6 +170,15 @@ rules::
179170
// ...
180171
}
181172
173+
.. code-block:: yaml
174+
175+
# src/AppBundle/Resources/config/validation.yml
176+
AppBundle\Entity\Document:
177+
properties:
178+
file:
179+
- File:
180+
maxSize: 6000000
181+
182182
.. code-block:: xml
183183
184184
<!-- src/AppBundle/Resources/config/validation.xml -->

cookbook/validation/custom_constraint.rst

+16-16
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ Using custom validators is very easy, just as the ones provided by Symfony itsel
8989

9090
.. configuration-block::
9191

92-
.. code-block:: yaml
93-
94-
# src/AppBundle/Resources/config/validation.yml
95-
AppBundle\Entity\AcmeEntity:
96-
properties:
97-
name:
98-
- NotBlank: ~
99-
- AppBundle\Validator\Constraints\ContainsAlphanumeric: ~
100-
10192
.. code-block:: php-annotations
10293
10394
// src/AppBundle/Entity/AcmeEntity.php
@@ -117,6 +108,15 @@ Using custom validators is very easy, just as the ones provided by Symfony itsel
117108
// ...
118109
}
119110
111+
.. code-block:: yaml
112+
113+
# src/AppBundle/Resources/config/validation.yml
114+
AppBundle\Entity\AcmeEntity:
115+
properties:
116+
name:
117+
- NotBlank: ~
118+
- AppBundle\Validator\Constraints\ContainsAlphanumeric: ~
119+
120120
.. code-block:: xml
121121
122122
<!-- src/AppBundle/Resources/config/validation.xml -->
@@ -237,13 +237,6 @@ not to the property:
237237

238238
.. configuration-block::
239239

240-
.. code-block:: yaml
241-
242-
# src/AppBundle/Resources/config/validation.yml
243-
AppBundle\Entity\AcmeEntity:
244-
constraints:
245-
- AppBundle\Validator\Constraints\ContainsAlphanumeric: ~
246-
247240
.. code-block:: php-annotations
248241
249242
/**
@@ -254,6 +247,13 @@ not to the property:
254247
// ...
255248
}
256249
250+
.. code-block:: yaml
251+
252+
# src/AppBundle/Resources/config/validation.yml
253+
AppBundle\Entity\AcmeEntity:
254+
constraints:
255+
- AppBundle\Validator\Constraints\ContainsAlphanumeric: ~
256+
257257
.. code-block:: xml
258258
259259
<!-- src/AppBundle/Resources/config/validation.xml -->

reference/constraints/All.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ entry in that array:
2222

2323
.. configuration-block::
2424

25-
.. code-block:: yaml
26-
27-
# src/Acme/UserBundle/Resources/config/validation.yml
28-
Acme\UserBundle\Entity\User:
29-
properties:
30-
favoriteColors:
31-
- All:
32-
- NotBlank: ~
33-
- Length:
34-
min: 5
35-
3625
.. code-block:: php-annotations
3726
3827
// src/Acme/UserBundle/Entity/User.php
@@ -51,6 +40,17 @@ entry in that array:
5140
protected $favoriteColors = array();
5241
}
5342
43+
.. code-block:: yaml
44+
45+
# src/Acme/UserBundle/Resources/config/validation.yml
46+
Acme\UserBundle\Entity\User:
47+
properties:
48+
favoriteColors:
49+
- All:
50+
- NotBlank: ~
51+
- Length:
52+
min: 5
53+
5454
.. code-block:: xml
5555
5656
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->

reference/constraints/Blank.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ of an ``Author`` class were blank, you could do the following:
2424

2525
.. configuration-block::
2626

27-
.. code-block:: yaml
28-
29-
# src/Acme/BlogBundle/Resources/config/validation.yml
30-
Acme\BlogBundle\Entity\Author:
31-
properties:
32-
firstName:
33-
- Blank: ~
34-
3527
.. code-block:: php-annotations
3628
3729
// src/Acme/BlogBundle/Entity/Author.php
@@ -47,6 +39,14 @@ of an ``Author`` class were blank, you could do the following:
4739
protected $firstName;
4840
}
4941
42+
.. code-block:: yaml
43+
44+
# src/Acme/BlogBundle/Resources/config/validation.yml
45+
Acme\BlogBundle\Entity\Author:
46+
properties:
47+
firstName:
48+
- Blank: ~
49+
5050
.. code-block:: xml
5151
5252
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->

reference/constraints/Callback.rst

+17-17
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ Setup
3232

3333
.. configuration-block::
3434

35-
.. code-block:: yaml
36-
37-
# src/Acme/BlogBundle/Resources/config/validation.yml
38-
Acme\BlogBundle\Entity\Author:
39-
constraints:
40-
- Callback:
41-
methods: [isAuthorValid]
42-
4335
.. code-block:: php-annotations
4436
4537
// src/Acme/BlogBundle/Entity/Author.php
@@ -54,6 +46,14 @@ Setup
5446
{
5547
}
5648
49+
.. code-block:: yaml
50+
51+
# src/Acme/BlogBundle/Resources/config/validation.yml
52+
Acme\BlogBundle\Entity\Author:
53+
constraints:
54+
- Callback:
55+
methods: [isAuthorValid]
56+
5757
.. code-block:: xml
5858
5959
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
@@ -139,15 +139,6 @@ process. Each method can be one of the following formats:
139139

140140
.. configuration-block::
141141

142-
.. code-block:: yaml
143-
144-
# src/Acme/BlogBundle/Resources/config/validation.yml
145-
Acme\BlogBundle\Entity\Author:
146-
constraints:
147-
- Callback:
148-
methods:
149-
- [Acme\BlogBundle\MyStaticValidatorClass, isAuthorValid]
150-
151142
.. code-block:: php-annotations
152143
153144
// src/Acme/BlogBundle/Entity/Author.php
@@ -162,6 +153,15 @@ process. Each method can be one of the following formats:
162153
{
163154
}
164155
156+
.. code-block:: yaml
157+
158+
# src/Acme/BlogBundle/Resources/config/validation.yml
159+
Acme\BlogBundle\Entity\Author:
160+
constraints:
161+
- Callback:
162+
methods:
163+
- [Acme\BlogBundle\MyStaticValidatorClass, isAuthorValid]
164+
165165
.. code-block:: xml
166166
167167
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->

reference/constraints/CardScheme.rst

+15-15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ on an object that will contain a credit card number.
2727

2828
.. configuration-block::
2929

30+
.. code-block:: php-annotations
31+
32+
// src/Acme/SubscriptionBundle/Entity/Transaction.php
33+
namespace Acme\SubscriptionBundle\Entity\Transaction;
34+
35+
use Symfony\Component\Validator\Constraints as Assert;
36+
37+
class Transaction
38+
{
39+
/**
40+
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
41+
*/
42+
protected $cardNumber;
43+
}
44+
3045
.. code-block:: yaml
3146
3247
# src/Acme/SubscriptionBundle/Resources/config/validation.yml
@@ -57,21 +72,6 @@ on an object that will contain a credit card number.
5772
</class>
5873
</constraint-mapping>
5974
60-
.. code-block:: php-annotations
61-
62-
// src/Acme/SubscriptionBundle/Entity/Transaction.php
63-
namespace Acme\SubscriptionBundle\Entity\Transaction;
64-
65-
use Symfony\Component\Validator\Constraints as Assert;
66-
67-
class Transaction
68-
{
69-
/**
70-
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
71-
*/
72-
protected $cardNumber;
73-
}
74-
7575
.. code-block:: php
7676
7777
// src/Acme/SubscriptionBundle/Entity/Transaction.php

reference/constraints/Choice.rst

+26-26
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ If your valid choice list is simple, you can pass them in directly via the
3636

3737
.. configuration-block::
3838

39-
.. code-block:: yaml
40-
41-
# src/Acme/BlogBundle/Resources/config/validation.yml
42-
Acme\BlogBundle\Entity\Author:
43-
properties:
44-
gender:
45-
- Choice:
46-
choices: [male, female]
47-
message: Choose a valid gender.
48-
4939
.. code-block:: php-annotations
5040
5141
// src/Acme/BlogBundle/Entity/Author.php
@@ -61,6 +51,16 @@ If your valid choice list is simple, you can pass them in directly via the
6151
protected $gender;
6252
}
6353
54+
.. code-block:: yaml
55+
56+
# src/Acme/BlogBundle/Resources/config/validation.yml
57+
Acme\BlogBundle\Entity\Author:
58+
properties:
59+
gender:
60+
- Choice:
61+
choices: [male, female]
62+
message: Choose a valid gender.
63+
6464
.. code-block:: xml
6565
6666
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
@@ -129,14 +129,6 @@ constraint.
129129

130130
.. configuration-block::
131131

132-
.. code-block:: yaml
133-
134-
# src/Acme/BlogBundle/Resources/config/validation.yml
135-
Acme\BlogBundle\Entity\Author:
136-
properties:
137-
gender:
138-
- Choice: { callback: getGenders }
139-
140132
.. code-block:: php-annotations
141133
142134
// src/Acme/BlogBundle/Entity/Author.php
@@ -152,6 +144,14 @@ constraint.
152144
protected $gender;
153145
}
154146
147+
.. code-block:: yaml
148+
149+
# src/Acme/BlogBundle/Resources/config/validation.yml
150+
Acme\BlogBundle\Entity\Author:
151+
properties:
152+
gender:
153+
- Choice: { callback: getGenders }
154+
155155
.. code-block:: xml
156156
157157
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
@@ -194,14 +194,6 @@ you can pass the class name and the method as an array.
194194

195195
.. configuration-block::
196196

197-
.. code-block:: yaml
198-
199-
# src/Acme/BlogBundle/Resources/config/validation.yml
200-
Acme\BlogBundle\Entity\Author:
201-
properties:
202-
gender:
203-
- Choice: { callback: [Util, getGenders] }
204-
205197
.. code-block:: php-annotations
206198
207199
// src/Acme/BlogBundle/Entity/Author.php
@@ -217,6 +209,14 @@ you can pass the class name and the method as an array.
217209
protected $gender;
218210
}
219211
212+
.. code-block:: yaml
213+
214+
# src/Acme/BlogBundle/Resources/config/validation.yml
215+
Acme\BlogBundle\Entity\Author:
216+
properties:
217+
gender:
218+
- Choice: { callback: [Util, getGenders] }
219+
220220
.. code-block:: xml
221221
222222
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->

0 commit comments

Comments
 (0)