@@ -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 ``Symfony\Component\Uid\Uid ``,
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 ``Symfony\Component\Uid\Uid``,
3636 class Author
3737 {
3838 /**
39- * @Assert\Type("Symfony\Component\Uid\Uid ")
39+ * @Assert\Type("Symfony\Component\Mime\Address ")
4040 */
41- protected $id ;
41+ protected $emailAddress ;
4242
4343 /**
4444 * @Assert\Type("string")
@@ -64,8 +64,8 @@ This will check if ``id`` is an instance of ``Symfony\Component\Uid\Uid``,
6464 # config/validator/validation.yaml
6565 App\Entity\Author :
6666 properties :
67- id :
68- - Type : Ramsey\Uuid\UuidInterface
67+ emailAddress :
68+ - Type : Symfony\Component\Mime\Address
6969
7070 firstName :
7171 - Type : string
@@ -88,9 +88,9 @@ This will check if ``id`` is an instance of ``Symfony\Component\Uid\Uid``,
8888 xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
8989
9090 <class name =" App\Entity\Author" >
91- <property name =" id " >
91+ <property name =" emailAddress " >
9292 <constraint name =" Type" >
93- <option name =" type" >Ramsey\Uuid\UuidInterface </option >
93+ <option name =" type" >Symfony\Component\Mime\Address </option >
9494 </constraint >
9595 </property >
9696 <property name =" firstName" >
@@ -120,15 +120,15 @@ This will check if ``id`` is an instance of ``Symfony\Component\Uid\Uid``,
120120 // src/Entity/Author.php
121121 namespace App\Entity;
122122
123- use Ramsey\Uuid\UuidInterface ;
123+ use Symfony\Component\Mime\Address ;
124124 use Symfony\Component\Validator\Constraints as Assert;
125125 use Symfony\Component\Validator\Mapping\ClassMetadata;
126126
127127 class Author
128128 {
129129 public static function loadValidatorMetadata(ClassMetadata $metadata)
130130 {
131- $metadata->addPropertyConstraint('id ', new Assert\Type(UuidInterface ::class));
131+ $metadata->addPropertyConstraint('emailAddress ', new Assert\Type(Address ::class));
132132
133133 $metadata->addPropertyConstraint('firstName', new Assert\Type('string'));
134134
0 commit comments