@@ -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 ``Ramsey\Uuid\UuidInterface ``,
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 ``Ramsey\Uuid\UuidInterface``,
36
36
class Author
37
37
{
38
38
/**
39
- * @Assert\Type("Ramsey\Uuid\UuidInterface ")
39
+ * @Assert\Type("Symfony\Component\Mime\Address ")
40
40
*/
41
- protected $id ;
41
+ protected $emailAddress ;
42
42
43
43
/**
44
44
* @Assert\Type("string")
@@ -90,8 +90,8 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
90
90
# config/validator/validation.yaml
91
91
App\Entity\Author :
92
92
properties :
93
- id :
94
- - Type : Ramsey\Uuid\UuidInterface
93
+ emailAddress :
94
+ - Type : Symfony\Component\Mime\Address
95
95
96
96
firstName :
97
97
- Type : string
@@ -114,9 +114,9 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
114
114
xsi : schemaLocation =" http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd" >
115
115
116
116
<class name =" App\Entity\Author" >
117
- <property name =" id " >
117
+ <property name =" emailAddress " >
118
118
<constraint name =" Type" >
119
- <option name =" type" >Ramsey\Uuid\UuidInterface </option >
119
+ <option name =" type" >Symfony\Component\Mime\Address </option >
120
120
</constraint >
121
121
</property >
122
122
<property name =" firstName" >
@@ -146,15 +146,15 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``,
146
146
// src/Entity/Author.php
147
147
namespace App\Entity;
148
148
149
- use Ramsey\Uuid\UuidInterface ;
149
+ use Symfony\Component\Mime\Address ;
150
150
use Symfony\Component\Validator\Constraints as Assert;
151
151
use Symfony\Component\Validator\Mapping\ClassMetadata;
152
152
153
153
class Author
154
154
{
155
155
public static function loadValidatorMetadata(ClassMetadata $metadata)
156
156
{
157
- $metadata->addPropertyConstraint('id ', new Assert\Type(UuidInterface ::class));
157
+ $metadata->addPropertyConstraint('emailAddress ', new Assert\Type(Address ::class));
158
158
159
159
$metadata->addPropertyConstraint('firstName', new Assert\Type('string'));
160
160
0 commit comments