File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,14 @@ Suppose you have an ``AcmeUserBundle`` with a ``User`` entity that has an
30
30
31
31
// Acme/UserBundle/Entity/User.php
32
32
use Symfony\Component\Validator\Constraints as Assert;
33
- use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
34
33
use Doctrine\ORM\Mapping as ORM;
35
34
35
+ // DON'T forget this use statement!!!
36
+ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
37
+
36
38
/**
37
39
* @ORM\Entity
38
- * @DoctrineAssert\ UniqueEntity("email")
40
+ * @UniqueEntity("email")
39
41
*/
40
42
class Author
41
43
{
@@ -53,8 +55,24 @@ Suppose you have an ``AcmeUserBundle`` with a ``User`` entity that has an
53
55
.. code-block :: yaml
54
56
55
57
# src/Acme/UserBundle/Resources/config/validation.yml
56
- constraints :
57
- - UniqueEntity : email
58
+ Acme\UserBundle\Entity\Author :
59
+ constraints :
60
+ - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity : email
61
+ properties :
62
+ email :
63
+ - Email : ~
64
+
65
+ .. code-block :: xml
66
+
67
+ <class name =" Acme\UserBundle\Entity\Author" >
68
+ <constraint name =" Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity" >
69
+ <option name =" fields" >email</option >
70
+ <option name =" message" >This email already exists.</option >
71
+ </constraint >
72
+ <property name =" email" >
73
+ <constraint name =" Email" />
74
+ </property >
75
+ </class >
58
76
59
77
Options
60
78
-------
You can’t perform that action at this time.
0 commit comments