Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac44303

Browse files
committed
Added missing xml configuration examples for validation constraints
1 parent2c2d4ff commitac44303

File tree

17 files changed

+184
-8
lines changed

17 files changed

+184
-8
lines changed

‎reference/constraints/All.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ entry in that array:
5151
protected $favoriteColors = array();
5252
}
5353
54+
..code-block::xml
55+
56+
<!-- src/Acme/UserBundle/Resources/config/validation.xml-->
57+
<classname="Acme\UserBundle\Entity\User">
58+
<propertyname="favoriteColors">
59+
<constraintname="All">
60+
<optionname="constraints">
61+
<constraintname="NotBlank" />
62+
<constraintname="Length">
63+
<optionname="min">5</option>
64+
</constraint>
65+
</option>
66+
</constraint>
67+
</property>
68+
</class>
69+
5470
Now, each entry in the ``favoriteColors`` array will be validated to not
5571
be blank and to be at least 5 characters long.
5672

‎reference/constraints/Choice.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If your valid choice list is simple, you can pass them in directly via the
4949
..code-block::xml
5050
5151
<!-- src/Acme/BlogBundle/Resources/config/validation.xml-->
52-
<classname="Acme\BlogBundle\EntityAuthor">
52+
<classname="Acme\BlogBundle\Entity\Author">
5353
<propertyname="gender">
5454
<constraintname="Choice">
5555
<optionname="choices">
@@ -280,4 +280,4 @@ strict
280280

281281
If true, the validator will also check the type of the input value. Specifically,
282282
this value is passed to as the third argument to the PHP:phpfunction:`in_array` method
283-
when checking to see if a value is in the valid choices array.
283+
when checking to see if a value is in the valid choices array.

‎reference/constraints/Count.rst‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ you might add the following:
3838
-Count:
3939
min:1
4040
max:5
41-
minMessage:You must specify at least one email
42-
maxMessage:You cannot specify more than5emails
41+
minMessage:"You must specify at least one email"
42+
maxMessage:"You cannot specify more than{{ limit }}emails"
4343
4444
..code-block::php-annotations
4545
@@ -53,12 +53,27 @@ you might add the following:
5353
* min = "1",
5454
* max = "5",
5555
* minMessage = "You must specify at least one email",
56-
* maxMessage = "You cannot specify more than5 emails"
56+
* maxMessage = "You cannot specify more than{{ limit }} emails"
5757
* )
5858
*/
5959
protected $emails = array();
6060
}
6161
62+
..code-block::xml
63+
64+
<!-- src/Acme/EventBundle/Resources/config/validation.xml-->
65+
<classname="Acme\EventBundle\Entity\Participant">
66+
<propertyname="emails">
67+
<constraintname="Count">
68+
<optionname="min">1</option>
69+
<optionname="max">5</option>
70+
<optionname="minMessage">You must specify at least one email</option>
71+
<optionname="maxMessage">You cannot specify more than {{ limit }} emails</option>
72+
</constraint>
73+
</property>
74+
</class>
75+
76+
6277
Options
6378
-------
6479

‎reference/constraints/Country.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Basic Usage
4141
protected $country;
4242
}
4343
44+
..code-block::xml
45+
46+
<!-- src/Acme/UserBundle/Resources/config/validation.xml-->
47+
<classname="Acme\UserBundle\Entity\User">
48+
<propertyname="country">
49+
<constraintname="Country" />
50+
</property>
51+
</class>
52+
4453
Options
4554
-------
4655

‎reference/constraints/Date.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Basic Usage
4141
protected $birthday;
4242
}
4343
44+
..code-block::xml
45+
46+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml-->
47+
<classname="Acme\BlogBundle\Entity\Author">
48+
<propertyname="birthday">
49+
<constraintname="Date" />
50+
</property>
51+
</class>
52+
4453
Options
4554
-------
4655

‎reference/constraints/DateTime.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ Basic Usage
4343
protected $createdAt;
4444
}
4545
46+
..code-block::xml
47+
48+
<!-- src/Acme/UserBundle/Resources/config/validation.xml-->
49+
<classname="Acme\BlogBundle\Entity\Author">
50+
<propertyname="createdAt">
51+
<constraintname="DateTime" />
52+
</property>
53+
</class>
54+
4655
Options
4756
-------
4857

‎reference/constraints/False.rst‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ method returns **false**:
4848
-"False":
4949
message:You've entered an invalid state.
5050
51+
..code-block::xml
52+
53+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml-->
54+
<classname="Acme\BlogBundle\Entity\Author">
55+
<getterproperty="stateInvalid">
56+
<constraintname="False">
57+
<optionname="message">You've entered an invalid state.</option>
58+
</constraint>
59+
</getter>
60+
</class>
61+
5162
..code-block::php-annotations
5263
5364
// src/Acme/BlogBundle/Entity/Author.php

‎reference/constraints/Ip.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ Basic Usage
4444
protected $ipAddress;
4545
}
4646
47+
..code-block::xml
48+
49+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml-->
50+
<classname="Acme\BlogBundle\Entity\Author">
51+
<propertyname="ipAddress">
52+
<constraintname="Ip" />
53+
</property>
54+
</class>
55+
4756
Options
4857
-------
4958

‎reference/constraints/Language.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Basic Usage
4141
protected $preferredLanguage;
4242
}
4343
44+
..code-block::xml
45+
46+
<!-- src/Acme/UserBundle/Resources/config/validation.xml-->
47+
<classname="Acme\UserBundle\Entity\User">
48+
<propertyname="preferredLanguage">
49+
<constraintname="Language" />
50+
</property>
51+
</class>
52+
4453
Options
4554
-------
4655

‎reference/constraints/Length.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ To verify that the ``firstName`` field length of a class is between "2" and
6161
6262
..code-block::xml
6363
64-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml-->
64+
<!-- src/Acme/EventBundle/Resources/config/validation.xml-->
6565
<classname="Acme\EventBundle\Entity\Participant">
6666
<propertyname="firstName">
6767
<constraintname="Length">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp