File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Basic Usage
3030The following constraints ensure that:
3131
3232* ``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
3434
3535.. configuration-block ::
3636
@@ -61,6 +61,8 @@ The following constraints ensure that:
6161 # src/AppBundle/Resources/config/validation.yml
6262 AppBundle\Entity\Person :
6363 properties :
64+ firstName :
65+ - IdenticalTo : Mary
6466 age :
6567 - IdenticalTo :
6668 value : 20
@@ -74,6 +76,11 @@ The following constraints ensure that:
7476 xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
7577
7678 <class name =" AppBundle\Entity\Person" >
79+ <property name =" firstName" >
80+ <constraint name =" IdenticalTo" >
81+ <value >Mary</value >
82+ </constraint >
83+ </property >
7784 <property name =" age" >
7885 <constraint name =" IdenticalTo" >
7986 <option name =" value" >20</option >
@@ -94,6 +101,8 @@ The following constraints ensure that:
94101 {
95102 public static function loadValidatorMetadata(ClassMetadata $metadata)
96103 {
104+ $metadata->addPropertyConstraint('firstName', new Assert\IdenticalTo('Mary'));
105+
97106 $metadata->addPropertyConstraint('age', new Assert\IdenticalTo(array(
98107 'value' => 20,
99108 )));
You can’t perform that action at this time.
0 commit comments