diff --git a/Form/Type/CouponType.php b/Form/Type/CouponType.php index b60c73d..75131ca 100644 --- a/Form/Type/CouponType.php +++ b/Form/Type/CouponType.php @@ -76,6 +76,7 @@ public function __construct(CouponRepository $couponRepository, ValidatorInterfa */ public function buildForm(FormBuilderInterface $builder, array $options) { + $max = 9999999999; $currency = $this->container->getParameter('currency'); $builder ->add('coupon_cd', TextType::class, [ @@ -85,6 +86,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'constraints' => [ new Assert\NotBlank(), new Assert\Regex(['pattern' => '/^[a-zA-Z0-9]+$/i']), + new Assert\Length([ + 'max' => 20, + ]), ], ]) ->add('coupon_name', TextType::class, [ @@ -93,6 +97,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'trim' => true, 'constraints' => [ new Assert\NotBlank(), + new Assert\Length([ + 'max' => 50, + ]), ], ]) ->add('coupon_type', ChoiceType::class, [ @@ -142,6 +149,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'constraints' => [ new Assert\Range([ 'min' => 0, + 'max'=> $max, ]), ], ]) @@ -152,6 +160,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'constraints' => [ new Assert\Range([ 'min' => 0, + 'max' => $max, ]), ], ]) @@ -173,6 +182,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'widget' => 'single_text', 'constraints' => [ new Assert\NotBlank(), + new Assert\Range([ + 'min'=> '0003-01-01', + 'minMessage' => 'form_error.out_of_range', + ]), ], ]) // 有効期間(TO) @@ -183,6 +196,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'widget' => 'single_text', 'constraints' => [ new Assert\NotBlank(), + new Assert\Range([ + 'min'=> '0003-01-01', + 'minMessage' => 'form_error.out_of_range', + ]), ], ]) ->add('coupon_release', IntegerType::class, [