Exemplo n.º 1
0
 function validate()
 {
     $errors = parent::validate();
     $validator = new Validator($this->_value);
     if (!$this->isMultiline()) {
         $validator->notRegexp("/\n/", sprintf("%s must be only one line", $this->getName()));
     }
     $this->_errors = array_merge($errors, $validator->allErrors());
     return $this->allErrors();
 }
Exemplo n.º 2
0
 function validate()
 {
     $errors = parent::validate();
     $validator = new Validator($this->_value);
     if ($this->_decimal) {
         $validator->float(sprintf("%s must be a number", $this->getName()));
     } else {
         $validator->integer(sprintf("%s must be a number", $this->getName()));
     }
     if ($this->_min_value) {
         $validator->min($this->_min_value, sprintf("%s must be greater than %f", $this->getName(), $this->_min_value));
     }
     if ($this->_max_value) {
         $validator->max($this->_max_value, sprintf("%s must be less than %f", $this->getName(), $this->_max_value));
     }
     $this->_errors = array_merge($errors, $validator->allErrors());
     return $this->allErrors();
 }