浏览代码

Merged in FD3-474 (pull request #7)

FD3-474 HostType validation campo name unique
Guillermo Espinoza 7 年之前
父节点
当前提交
57a715d0a0
共有 1 个文件被更改,包括 9 次插入0 次删除
  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;