File tree 1 file changed +10
-1
lines changed 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Basic Usage
30
30
The following constraints ensure that:
31
31
32
32
* ``firstName `` of ``Person `` class is equal to ``Mary `` *and * is a string
33
- * ``age `` is equal to``20`` *and * is of type integer
33
+ * ``age `` is equal to ``20 `` *and * is of type integer
34
34
35
35
.. configuration-block ::
36
36
@@ -61,6 +61,8 @@ The following constraints ensure that:
61
61
# src/AppBundle/Resources/config/validation.yml
62
62
AppBundle\Entity\Person :
63
63
properties :
64
+ firstName :
65
+ - IdenticalTo : Mary
64
66
age :
65
67
- IdenticalTo :
66
68
value : 20
@@ -74,6 +76,11 @@ The following constraints ensure that:
74
76
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
75
77
76
78
<class name =" AppBundle\Entity\Person" >
79
+ <property name =" firstName" >
80
+ <constraint name =" IdenticalTo" >
81
+ <value >Mary</value >
82
+ </constraint >
83
+ </property >
77
84
<property name =" age" >
78
85
<constraint name =" IdenticalTo" >
79
86
<option name =" value" >20</option >
@@ -94,6 +101,8 @@ The following constraints ensure that:
94
101
{
95
102
public static function loadValidatorMetadata(ClassMetadata $metadata)
96
103
{
104
+ $metadata->addPropertyConstraint('firstName', new Assert\IdenticalTo('Mary'));
105
+
97
106
$metadata->addPropertyConstraint('age', new Assert\IdenticalTo(array(
98
107
'value' => 20,
99
108
)));
You can’t perform that action at this time.
0 commit comments