Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 627d74d

Browse files
Tim Stampweaverryan
Tim Stamp
authored andcommitted
Updated constraint reference docs for Null->IsNull, False->IsFalse, True->IsTrue
1 parent a90ea7c commit 627d74d

File tree

4 files changed

+37
-65
lines changed

4 files changed

+37
-65
lines changed

reference/constraints/Blank.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Blank
33

44
Validates that a value is blank, defined as equal to a blank string or equal
55
to ``null``. To force that a value strictly be equal to ``null``, see the
6-
:doc:`/reference/constraints/Null` constraint. To force that a value is
6+
:doc:`/reference/constraints/IsNull` constraint. To force that a value is
77
*not* blank, see :doc:`/reference/constraints/NotBlank`.
88

99
+----------------+---------------------------------------------------------------------+

reference/constraints/IsFalse.rst

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
1-
False
2-
=====
3-
4-
.. caution::
5-
6-
The ``False`` constraint is deprecated since Symfony 2.7
7-
and will be removed in Symfony 3.0. Use the ``IsFalse`` constraint instead.
1+
IsFalse
2+
=======
83

94
Validates that a value is ``false``. Specifically, this checks to see if
105
the value is exactly ``false``, exactly the integer ``0``, or exactly the
116
string "``0``".
127

13-
Also see :doc:`True <True>`.
8+
Also see :doc:`IsTrue <IsTrue>`.
149

15-
+----------------+---------------------------------------------------------------------+
16-
| Applies to | :ref:`property or method <validation-property-target>` |
17-
+----------------+---------------------------------------------------------------------+
18-
| Options | - `message`_ |
19-
+----------------+---------------------------------------------------------------------+
20-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\False` |
21-
+----------------+---------------------------------------------------------------------+
22-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\FalseValidator` |
23-
+----------------+---------------------------------------------------------------------+
10+
+----------------+-----------------------------------------------------------------------+
11+
| Applies to | :ref:`property or method <validation-property-target>` |
12+
+----------------+-----------------------------------------------------------------------+
13+
| Options | - `message`_ |
14+
+----------------+-----------------------------------------------------------------------+
15+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsFalse` |
16+
+----------------+-----------------------------------------------------------------------+
17+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsFalseValidator` |
18+
+----------------+-----------------------------------------------------------------------+
2419

2520
Basic Usage
2621
-----------
2722

28-
The ``False`` constraint can be applied to a property or a "getter" method,
23+
The ``IsFalse`` constraint can be applied to a property or a "getter" method,
2924
but is most commonly useful in the latter case. For example, suppose that
3025
you want to guarantee that some ``state`` property is *not* in a dynamic
3126
``invalidStates`` array. First, you'd create a "getter" method::
@@ -54,7 +49,7 @@ method returns **false**:
5449
class Author
5550
{
5651
/**
57-
* @Assert\False(
52+
* @Assert\IsFalse(
5853
* message = "You've entered an invalid state."
5954
* )
6055
*/
@@ -70,7 +65,7 @@ method returns **false**:
7065
AppBundle\Entity\Author
7166
getters:
7267
stateInvalid:
73-
- 'False':
68+
- 'IsFalse':
7469
message: You've entered an invalid state.
7570
7671
.. code-block:: xml
@@ -83,7 +78,7 @@ method returns **false**:
8378
8479
<class name="AppBundle\Entity\Author">
8580
<getter property="stateInvalid">
86-
<constraint name="False">
81+
<constraint name="IsFalse">
8782
<option name="message">You've entered an invalid state.</option>
8883
</constraint>
8984
</getter>
@@ -102,15 +97,10 @@ method returns **false**:
10297
{
10398
public static function loadValidatorMetadata(ClassMetadata $metadata)
10499
{
105-
$metadata->addGetterConstraint('stateInvalid', new Assert\False());
100+
$metadata->addGetterConstraint('stateInvalid', new Assert\IsFalse());
106101
}
107102
}
108103
109-
.. caution::
110-
111-
When using YAML, be sure to surround ``False`` with quotes (``'False'``)
112-
or else YAML will convert this into a ``false`` boolean value.
113-
114104
Options
115105
-------
116106

reference/constraints/IsNull.rst

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
Null
2-
====
3-
4-
.. caution::
5-
6-
The ``Null`` constraint is deprecated since Symfony 2.7
7-
and will be removed in Symfony 3.0. Use the ``IsNull`` constraint instead.
1+
IsNull
2+
======
83

94
Validates that a value is exactly equal to ``null``. To force that a property
105
is simply blank (blank string or ``null``), see the :doc:`/reference/constraints/Blank`
116
constraint. To ensure that a property is not null, see :doc:`/reference/constraints/NotNull`.
127

8+
Also see :doc:`NotNull <NotNull>`.
9+
1310
+----------------+-----------------------------------------------------------------------+
1411
| Applies to | :ref:`property or method <validation-property-target>` |
1512
+----------------+-----------------------------------------------------------------------+
1613
| Options | - `message`_ |
1714
+----------------+-----------------------------------------------------------------------+
18-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Null` |
15+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsNull` |
1916
+----------------+-----------------------------------------------------------------------+
20-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\NullValidator` |
17+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsNullValidator` |
2118
+----------------+-----------------------------------------------------------------------+
2219

2320
Basic Usage
@@ -38,7 +35,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following:
3835
class Author
3936
{
4037
/**
41-
* @Assert\Null()
38+
* @Assert\IsNull()
4239
*/
4340
protected $firstName;
4441
}
@@ -49,7 +46,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following:
4946
AppBundle\Entity\Author:
5047
properties:
5148
firstName:
52-
- 'Null': ~
49+
- 'IsNull': ~
5350
5451
.. code-block:: xml
5552
@@ -61,7 +58,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following:
6158
6259
<class name="AppBundle\Entity\Author">
6360
<property name="firstName">
64-
<constraint name="Null" />
61+
<constraint name="IsNull" />
6562
</property>
6663
</class>
6764
</constraint-mapping>
@@ -78,15 +75,10 @@ of an ``Author`` class exactly equal to ``null``, you could do the following:
7875
{
7976
public static function loadValidatorMetadata(ClassMetadata $metadata)
8077
{
81-
$metadata->addPropertyConstraint('firstName', Assert\Null());
78+
$metadata->addPropertyConstraint('firstName', Assert\IsNull());
8279
}
8380
}
8481
85-
.. caution::
86-
87-
When using YAML, be sure to surround ``Null`` with quotes (``'Null'``)
88-
or else YAML will convert this into a ``null`` value.
89-
9082
Options
9183
-------
9284

reference/constraints/IsTrue.rst

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
True
2-
====
3-
4-
.. caution::
5-
6-
The ``True`` constraint is deprecated since Symfony 2.7
7-
and will be removed in Symfony 3.0. Use the ``IsTrue`` constraint instead.
1+
IsTrue
2+
======
83

94
Validates that a value is ``true``. Specifically, this checks to see if
105
the value is exactly ``true``, exactly the integer ``1``, or exactly the
116
string "``1``".
127

13-
Also see :doc:`False <False>`.
8+
Also see :doc:`IsFalse <IsFalse>`.
149

1510
+----------------+---------------------------------------------------------------------+
1611
| Applies to | :ref:`property or method <validation-property-target>` |
@@ -43,7 +38,7 @@ For example, suppose you have the following method::
4338
}
4439
}
4540

46-
Then you can constrain this method with ``True``.
41+
Then you can constrain this method with ``IsTrue``.
4742

4843
.. configuration-block::
4944

@@ -59,7 +54,7 @@ Then you can constrain this method with ``True``.
5954
protected $token;
6055
6156
/**
62-
* @Assert\True(message = "The token is invalid")
57+
* @Assert\IsTrue(message = "The token is invalid")
6358
*/
6459
public function isTokenValid()
6560
{
@@ -73,7 +68,7 @@ Then you can constrain this method with ``True``.
7368
AppBundle\Entity\Author:
7469
getters:
7570
tokenValid:
76-
- 'True':
71+
- 'IsTrue':
7772
message: The token is invalid.
7873
7974
.. code-block:: xml
@@ -86,7 +81,7 @@ Then you can constrain this method with ``True``.
8681
8782
<class name="AppBundle\Entity\Author">
8883
<getter property="tokenValid">
89-
<constraint name="True">
84+
<constraint name="IsTrue">
9085
<option name="message">The token is invalid.</option>
9186
</constraint>
9287
</getter>
@@ -99,15 +94,15 @@ Then you can constrain this method with ``True``.
9994
namespace AppBundle\Entity;
10095
10196
use Symfony\Component\Validator\Mapping\ClassMetadata;
102-
use Symfony\Component\Validator\Constraints\True;
97+
use Symfony\Component\Validator\Constraints\IsTrue;
10398
10499
class Author
105100
{
106101
protected $token;
107102
108103
public static function loadValidatorMetadata(ClassMetadata $metadata)
109104
{
110-
$metadata->addGetterConstraint('tokenValid', new True(array(
105+
$metadata->addGetterConstraint('tokenValid', new IsTrue(array(
111106
'message' => 'The token is invalid.',
112107
)));
113108
}
@@ -120,11 +115,6 @@ Then you can constrain this method with ``True``.
120115
121116
If the ``isTokenValid()`` returns false, the validation will fail.
122117

123-
.. caution::
124-
125-
When using YAML, be sure to surround ``True`` with quotes (``'True'``)
126-
or else YAML will convert this into a ``true`` boolean value.
127-
128118
Options
129119
-------
130120

0 commit comments

Comments
 (0)