/** * {@inheritDoc} */ public function validate($value) { if (is_array($value)) { for ($i = 0, $count = count($value); $i < $count; ++$i) { if (!$this->validate($value[$i])) { return false; } } return true; } $numericValidator = new NumericValidator(); $numericValidator->setRule(new NumericRule()); if (!$numericValidator->validate($value)) { return false; } $min = $this->rule->getMin(); if (is_int($min)) { if ($value < $min) { $this->setMessage($this->rule->getMinMessage()); return false; } } $max = $this->rule->getMax(); if (is_int($max)) { if ($value > $max) { $this->setMessage($this->rule->getMaxMessage()); return false; } } return true; }
public function numeric_value() { return ValidationConfig::create()->addRequired('必須入力です')->addRange('数値が不正です', RangeRule::create()->setMax(5, '5以内で入力して下さい')->setMin(2, '2以上で入力して下さい')); }
public function selection() { return ValidationConfig::create()->addRequired('必須入力です')->addRange('1か2を選択して下さい', RangeRule::create()->setMin(1)->setMax(2)); }