@@ -18,7 +18,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\TypeValidator`
18
18
Basic Usage
19
19
-----------
20
20
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 ``,
22
22
``firstName `` is of type ``string `` (using :phpfunction: `is_string ` PHP function),
23
23
``age `` is an ``integer `` (using :phpfunction: `is_int ` PHP function) and
24
24
``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``,
36
36
class Author
37
37
{
38
38
/**
39
- * @Assert\Type("Symfony\Component\Uid\Uid ")
39
+ * @Assert\Type("Symfony\Component\Mime\Address ")
40
40
*/
41
- protected $id ;
41
+ protected $emailAddress ;
42
42
43
43
/**
44
44
* @Assert\Type("string")
@@ -64,8 +64,8 @@ This will check if ``id`` is an instance of ``Symfony\Component\Uid\Uid``,
64
64
# config/validator/validation.yaml
65
65
App\Entity\Author :
66
66
properties :
67
- id :
68
- - Type : Ramsey\Uuid\UuidInterface
67
+ emailAddress :
68
+ - Type : Symfony\Component\Mime\Address
69
69
70
70
firstName :
71
71
- Type : string
@@ -88,9 +88,9 @@ This will check if ``id`` is an instance of ``Symfony\Component\Uid\Uid``,
88
88
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
89
89
90
90
<class name =" App\Entity\Author" >
91
- <property name =" id " >
91
+ <property name =" emailAddress " >
92
92
<constraint name =" Type" >
93
- <option name =" type" >Ramsey\Uuid\UuidInterface </option >
93
+ <option name =" type" >Symfony\Component\Mime\Address </option >
94
94
</constraint >
95
95
</property >
96
96
<property name =" firstName" >
@@ -120,15 +120,15 @@ This will check if ``id`` is an instance of ``Symfony\Component\Uid\Uid``,
120
120
// src/Entity/Author.php
121
121
namespace App\Entity;
122
122
123
- use Ramsey\Uuid\UuidInterface ;
123
+ use Symfony\Component\Mime\Address ;
124
124
use Symfony\Component\Validator\Constraints as Assert;
125
125
use Symfony\Component\Validator\Mapping\ClassMetadata;
126
126
127
127
class Author
128
128
{
129
129
public static function loadValidatorMetadata(ClassMetadata $metadata)
130
130
{
131
- $metadata->addPropertyConstraint('id ', new Assert\Type(UuidInterface ::class));
131
+ $metadata->addPropertyConstraint('emailAddress ', new Assert\Type(Address ::class));
132
132
133
133
$metadata->addPropertyConstraint('firstName', new Assert\Type('string'));
134
134
0 commit comments