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
94Validates that a value is ``false ``. Specifically, this checks to see if
105the value is exactly ``false ``, exactly the integer ``0 ``, or exactly the
116string "``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
2520Basic 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,
2924but is most commonly useful in the latter case. For example, suppose that
3025you 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
0 commit comments