From 91051f86a812570c3fea00e9feba3c5e0ebfcd8d Mon Sep 17 00:00:00 2001 From: hidenorigoto Date: Mon, 21 Sep 2015 09:14:05 +0900 Subject: [PATCH] =?UTF-8?q?[6-3]=20Inquiry=E3=82=A8=E3=83=B3=E3=83=86?= =?UTF-8?q?=E3=82=A3=E3=83=86=E3=82=A3=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AB?= =?UTF-8?q?=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/lists/ch06/06-03.txt | 57 ++++++++++++++++++++++++++++++++ src/AppBundle/Entity/Inquiry.php | 10 ++++++ 2 files changed, 67 insertions(+) create mode 100644 docs/lists/ch06/06-03.txt diff --git a/docs/lists/ch06/06-03.txt b/docs/lists/ch06/06-03.txt new file mode 100644 index 0000000..98d6b25 --- /dev/null +++ b/docs/lists/ch06/06-03.txt @@ -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; + ... +} diff --git a/src/AppBundle/Entity/Inquiry.php b/src/AppBundle/Entity/Inquiry.php index 4f318b0..1e241e2 100644 --- a/src/AppBundle/Entity/Inquiry.php +++ b/src/AppBundle/Entity/Inquiry.php @@ -3,6 +3,7 @@ namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints As Assert; /** * Inquiry @@ -25,6 +26,8 @@ class Inquiry * @var string * * @ORM\Column(name="name", type="string", length=30) + * @Assert\NotBlank() + * @Assert\Length(max=30) */ private $name; @@ -32,6 +35,9 @@ class Inquiry * @var string * * @ORM\Column(name="email", type="string", length=100) + * @Assert\NotBlank() + * @Assert\Length(max=100) + * @Assert\Email() */ private $email; @@ -39,6 +45,8 @@ class Inquiry * @var string * * @ORM\Column(name="tel", type="string", length=20, nullable=true) + * @Assert\Length(max=20) + * @Assert\Regex(pattern="/^[0-9-]+$/") */ private $tel; @@ -46,6 +54,7 @@ class Inquiry * @var string * * @ORM\Column(name="type", type="string", length=20) + * @Assert\NotBlank() */ private $type; @@ -53,6 +62,7 @@ class Inquiry * @var string * * @ORM\Column(name="content", type="text") + * @Assert\NotBlank() */ private $content;