Jelajahi Sumber

Merged in FD3-474 (pull request #7)

FD3-474 HostType validation campo name unique
Guillermo Espinoza 7 tahun lalu
induk
melakukan
57a715d0a0
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      src/IPv4Bundle/Entity/HostType.php

+ 9 - 0
src/IPv4Bundle/Entity/HostType.php

@@ -3,9 +3,14 @@
 namespace IPv4Bundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Constraints as Assert;
 
 /**
  * @ORM\Entity
+ *
+ * @UniqueEntity("name")
+ * @UniqueEntity("shortname")
  */
 class HostType
 {
@@ -23,6 +28,8 @@ class HostType
      * @var string $name
      *
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
     protected $name;
 
@@ -30,6 +37,8 @@ class HostType
      * @var string $shortname
      *
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
     protected $shortname;