From 277ac8e05b7ec9b95a8af8faf12ba3a6f74b777c Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Wed, 10 Jan 2018 04:41:50 +0800 Subject: [PATCH] Add assert constraints to role entity --- src/Entity/Role.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Entity/Role.php b/src/Entity/Role.php index 107e7430..168b127d 100644 --- a/src/Entity/Role.php +++ b/src/Entity/Role.php @@ -4,10 +4,14 @@ namespace App\Entity; 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; /** * @ORM\Entity * @ORM\Table(name="role") + * @UniqueEntity("id") + * @UniqueEntity("name") */ class Role { @@ -16,11 +20,13 @@ class Role /** * @ORM\Id * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $id; /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $name;