Skip to content

Commit 4e23fee

Browse files
committed
Add missing xml reference examples. Fix MaxLength example
1 parent 44a963f commit 4e23fee

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed

reference/constraints/Blank.rst

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ of an ``Author`` class were blank, you could do the following:
4343
protected $firstName;
4444
}
4545
46+
.. code-block:: xml
47+
48+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
49+
<class name="Acme\BlogBundle\Entity\Author">
50+
<property name="firstName">
51+
<constraint name="Blank" />
52+
</property>
53+
</class>
54+
4655
Options
4756
-------
4857

reference/constraints/Length.rst

+18-4
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ To verify that the ``firstName`` field length of a class is between "2" and
3838
- Length:
3939
min: 2
4040
max: 50
41-
minMessage: Your first name must be at least 2 characters length
42-
maxMessage: Your first name cannot be longer than than 50 characters length
41+
minMessage: "Your first name must be at least {{ limit }} characters length"
42+
maxMessage: "Your first name cannot be longer than than {{ limit }} characters length"
4343
4444
.. code-block:: php-annotations
4545
@@ -52,13 +52,27 @@ To verify that the ``firstName`` field length of a class is between "2" and
5252
* @Assert\Length(
5353
* min = "2",
5454
* max = "50",
55-
* minMessage = "Your first name must be at least 2 characters length",
56-
* maxMessage = "Your first name cannot be longer than than 50 characters length"
55+
* minMessage = "Your first name must be at least {{ limit }} characters length",
56+
* maxMessage = "Your first name cannot be longer than than {{ limit }} characters length"
5757
* )
5858
*/
5959
protected $firstName;
6060
}
6161
62+
.. code-block:: xml
63+
64+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
65+
<class name="Acme\EventBundle\Entity\Participant">
66+
<property name="firstName">
67+
<constraint name="Length">
68+
<option name="min">2</option>
69+
<option name="max">50</option>
70+
<option name="minMessage">Your first name must be at least {{ limit }} characters length</option>
71+
<option name="maxMessage">Your first name cannot be longer than than {{ limit }} characters length</option>
72+
</constraint>
73+
</property>
74+
</class>
75+
6276
Options
6377
-------
6478

reference/constraints/MaxLength.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Basic Usage
5353
<class name="Acme\BlogBundle\Entity\Blog">
5454
<property name="summary">
5555
<constraint name="MaxLength">
56-
<value>100</value>
56+
<option name="limit">100</option>
5757
</constraint>
5858
</property>
5959
</class>

reference/constraints/NotBlank.rst

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ were not blank, you could do the following:
4242
protected $firstName;
4343
}
4444
45+
.. code-block:: xml
46+
47+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
48+
<class name="Acme\BlogBundle\Entity\Author">
49+
<property name="firstName">
50+
<constraint name="NotBlank" />
51+
</property>
52+
</class>
53+
4554
Options
4655
-------
4756

reference/constraints/NotNull.rst

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ were not strictly equal to ``null``, you would:
4242
protected $firstName;
4343
}
4444
45+
.. code-block:: xml
46+
47+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
48+
<class name="Acme\BlogBundle\Entity\Author">
49+
<property name="firstName">
50+
<constraint name="NotNull" />
51+
</property>
52+
</class>
53+
4554
Options
4655
-------
4756

reference/constraints/Null.rst

+9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ of an ``Author`` class exactly equal to ``null``, you could do the following:
4646
protected $firstName;
4747
}
4848
49+
.. code-block:: xml
50+
51+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
52+
<class name="Acme\BlogBundle\Entity\Author">
53+
<property name="firstName">
54+
<constraint name="Null" />
55+
</property>
56+
</class>
57+
4958
Options
5059
-------
5160

0 commit comments

Comments
 (0)