Add validation asserts to user entity
This commit is contained in:
parent
2cced6a4a5
commit
0b46565f7a
1 changed files with 7 additions and 0 deletions
|
|
@ -5,11 +5,15 @@ namespace App\Entity;
|
|||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Serializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="user")
|
||||
* @UniqueEntity("username")
|
||||
* @UniqueEntity("email")
|
||||
*/
|
||||
class User implements AdvancedUserInterface, Serializable
|
||||
{
|
||||
|
|
@ -22,6 +26,8 @@ class User implements AdvancedUserInterface, Serializable
|
|||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80, unique=true)
|
||||
* @Assert\NotBlank()
|
||||
*
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
|
|
@ -33,6 +39,7 @@ class User implements AdvancedUserInterface, Serializable
|
|||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Role", inversedBy="users")
|
||||
* @ORM\JoinTable(name="user_role")
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
protected $roles;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue