/** * {@inheritDoc} */ public function validate($value) { if (is_int($this->rule->getMax())) { if (count($value) > $this->rule->getMax()) { $this->setMessage($this->rule->getMaxMessage()); return false; } } if (is_int($this->rule->getMin())) { if (count($value) < $this->rule->getMin()) { $this->setMessage($this->rule->getMinMessage()); return false; } } return true; }
public function married() { $rule = new ChoiceRule(); return ValidationConfig::create()->addRequired('必須入力です')->addChoice('2つ以上3つ以下で選択して下さい', ChoiceRule::create()->setMax(3, '3つ以下で選択して下さい')->setMin(2, '2つ以上選択して下さい')); }