Skip to content
Permalink
Browse files

[6-3] Inquiryエンティティクラスにバリデーション定義を追加

  • Loading branch information...
hidenorigoto committed Sep 21, 2015
1 parent d187143 commit 91051f86a812570c3fea00e9feba3c5e0ebfcd8d
Showing with 67 additions and 0 deletions.
  1. +57 −0 docs/lists/ch06/06-03.txt
  2. +10 −0 src/AppBundle/Entity/Inquiry.php
@@ -0,0 +1,57 @@
...
use Doctrine\ORM\Mapping as ORM;
...
/**
* Inquiry
*
* @ORM\Table(name="inquiry")
* @ORM\Entity(repositoryClass="AppBundle\Entity\InquiryRepository")
*/
class Inquiry
{
...
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=30)
* @Assert\NotBlank()
* @Assert\Length(max=30)
*/
private $name;

/**
* @var string
*
* @ORM\Column(name="email", type="string", length=100)
* @Assert\NotBlank()
* @Assert\Length(max=100)
* @Assert\Email()
*/
private $email;

/**
* @var string
*
* @ORM\Column(name="tel", type="string", length=20, nullable=true)
* @Assert\Length(max=20)
* @Assert\Regex(pattern="/^[0-9-]+$/")
*/
private $tel;

/**
* @var string
*
* @ORM\Column(name="type", type="string", length=20)
* @Assert\NotBlank()
*/
private $type;

/**
* @var string
*
* @ORM\Column(name="content", type="text")
* @Assert\NotBlank()
*/
private $content;
...
}
@@ -3,6 +3,7 @@
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints As Assert;
/**
* Inquiry
@@ -25,34 +26,43 @@ class Inquiry
* @var string
*
* @ORM\Column(name="name", type="string", length=30)
* @Assert\NotBlank()
* @Assert\Length(max=30)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=100)
* @Assert\NotBlank()
* @Assert\Length(max=100)
* @Assert\Email()
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="tel", type="string", length=20, nullable=true)
* @Assert\Length(max=20)
* @Assert\Regex(pattern="/^[0-9-]+$/")
*/
private $tel;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=20)
* @Assert\NotBlank()
*/
private $type;
/**
* @var string
*
* @ORM\Column(name="content", type="text")
* @Assert\NotBlank()
*/
private $content;

0 comments on commit 91051f8

Please sign in to comment.
You can’t perform that action at this time.