8000 fix #10829: add missing examples in IdenticalTo constraint · nikophil/symfony-docs@ad78e1b · GitHub
[go: up one dir, main page]

Skip to content

Commit ad78e1b

Browse files
committed
fix symfony#10829: add missing examples in IdenticalTo constraint
1 parent bb557d4 commit ad78e1b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

reference/constraints/IdenticalTo.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Basic Usage
3030
The 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
)));

0 commit comments

Comments
 (0)
0