コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function validate($value)
 {
     $length = mb_strlen($value);
     $min = $this->rule->getMin();
     if (is_int($min)) {
         if ($length < $min) {
             $this->setMessage($this->rule->getMinMessage());
             return false;
         }
     }
     $max = $this->rule->getMax();
     if (is_int($max)) {
         if ($length > $max) {
             $this->setMessage($this->rule->getMaxMessage());
             return false;
         }
     }
     return true;
 }
コード例 #2
0
 public function string_value()
 {
     return ValidationConfig::create()->addRequired('必須入力です')->addLength('文字数が不正です', LengthRule::create()->setMax(5, '5バイト以内で入力して下さい')->setMin(2, '2バイト以上で入力して下さい'));
 }