Пример #1
0
 /**
  * @param mixed $value
  * @return bool
  * @throws \WPametu\Exception\ValidateException
  */
 protected function validate($value)
 {
     if (parent::validate($value)) {
         if (!$this->is_allowed_value($value)) {
             throw new ValidateException(sprintf($this->__('Field %s is invalid.'), $this->label));
         }
         return true;
     } else {
         return false;
     }
 }
Пример #2
0
 /**
  * Validator
  *
  * @param mixed $value
  * @return bool
  * @throws \WPametu\Exception\ValidateException
  */
 protected function validate($value)
 {
     if (parent::validate($value)) {
         $length = mb_strlen($value, 'utf-8');
         if ($this->min && $this->min > $length) {
             throw new ValidateException(sprintf($this->__('Fields %s must be %d digits and more.'), $this->label, $this->min));
         }
         if ($this->max && $this->max < $length) {
             throw new ValidateException(sprintf($this->__('Fields %s must be %d digits and fewer.'), $this->label, $this->max));
         }
     }
     return true;
 }