ソースを参照

FD3-474 HostType validation campo name unique

Guillermo Espinoza 7 年 前
コミット
b0450d7cad
1 ファイル変更12 行追加0 行削除
  1. 12 0
      src/IPv4Bundle/Entity/HostType.php

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

@@ -3,9 +3,15 @@
 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")
+ * @UniqueEntity("opcode")
  */
 class HostType
 {
@@ -23,6 +29,8 @@ class HostType
      * @var string $name
      *
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
     protected $name;
 
@@ -30,6 +38,8 @@ class HostType
      * @var string $shortname
      *
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
     protected $shortname;
 
@@ -37,6 +47,8 @@ class HostType
      * @var string $opcode
      *
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
     protected $opcode;