浏览代码

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;
 namespace IPv4Bundle\Entity;
 
 
 use Doctrine\ORM\Mapping as ORM;
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Constraints as Assert;
 
 
 /**
 /**
  * @ORM\Entity
  * @ORM\Entity
+ *
+ * @UniqueEntity("name")
+ * @UniqueEntity("shortname")
+ * @UniqueEntity("opcode")
  */
  */
 class HostType
 class HostType
 {
 {
@@ -23,6 +29,8 @@ class HostType
      * @var string $name
      * @var string $name
      *
      *
      * @ORM\Column(type="string", length=100, unique=true)
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
      */
     protected $name;
     protected $name;
 
 
@@ -30,6 +38,8 @@ class HostType
      * @var string $shortname
      * @var string $shortname
      *
      *
      * @ORM\Column(type="string", length=100, unique=true)
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
      */
     protected $shortname;
     protected $shortname;
 
 
@@ -37,6 +47,8 @@ class HostType
      * @var string $opcode
      * @var string $opcode
      *
      *
      * @ORM\Column(type="string", length=100, unique=true)
      * @ORM\Column(type="string", length=100, unique=true)
+     *
+     * @Assert\NotBlank
      */
      */
     protected $opcode;
     protected $opcode;