@@ -18,7 +18,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\TypeValidator`
1818Basic Usage
1919-----------
2020
21- This will check if ``id `` is an instance of ``Ramsey\Uuid\UuidInterface ``,
21+ This will check if ``emailAddress `` is an instance of ``Symfony\Component\Mime\Address ``,
2222``firstName `` is of type ``string `` (using :phpfunction: `is_string ` PHP function),
2323``age `` is an ``integer `` (using :phpfunction: `is_int ` PHP function) and
2424``accessCode `` contains either only letters or only digits (using
@@ -36,9 +36,9 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
3636 class Author
3737 {
3838 /**
39- * @Assert\Type("Ramsey\Uuid\UuidInterface ")
39+ * @Assert\Type("Symfony\Component\Mime\Address ")
4040 */
41- protected $id ;
41+ protected $emailAddress ;
4242
4343 /**
4444 * @Assert\Type("string")
@@ -90,8 +90,8 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
9090 # config/validator/validation.yaml
9191 App\Entity\Author :
9292 properties :
93- id :
94- - Type : Ramsey\Uuid\UuidInterface
93+ emailAddress :
94+ - Type : Symfony\Component\Mime\Address
9595
9696 firstName :
9797 - Type : string
@@ -114,9 +114,9 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
114114 xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
115115
116116 <class name =" App\Entity\Author" >
117- <property name =" id " >
117+ <property name =" emailAddress " >
118118 <constraint name =" Type" >
119- <option name =" type" >Ramsey\Uuid\UuidInterface </option >
119+ <option name =" type" >Symfony\Component\Mime\Address </option >
120120 </constraint >
121121 </property >
122122 <property name =" firstName" >
@@ -146,15 +146,15 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
146146 // src/Entity/Author.php
147147 namespace App\Entity;
148148
149- use Ramsey\Uuid\UuidInterface ;
149+ use Symfony\Component\Mime\Address ;
150150 use Symfony\Component\Validator\Constraints as Assert;
151151 use Symfony\Component\Validator\Mapping\ClassMetadata;
152152
153153 class Author
154154 {
155155 public static function loadValidatorMetadata(ClassMetadata $metadata)
156156 {
157- $metadata->addPropertyConstraint('id ', new Assert\Type(UuidInterface ::class));
157+ $metadata->addPropertyConstraint('emailAddress ', new Assert\Type(Address ::class));
158158
159159 $metadata->addPropertyConstraint('firstName', new Assert\Type('string'));
160160
0 commit comments