Example #1
0
 public function check()
 {
     if (!$this->required && !$this->value) {
         return;
     }
     if ($error = parent::check()) {
         return $error;
     }
     if (!is_numeric($this->value)) {
         return array('number', $this->printName());
     }
     if ($this->min !== null) {
         if ($this->value < $this->min) {
             return array('number_min', $this->printName(), $this->min);
         }
     }
     if ($this->max !== null) {
         if ($this->value > $this->max) {
             return array('number_max', $this->printName(), $this->max);
         }
     }
     if ($this->step != 'any') {
         $step = abs((double) $this->step);
         $value = abs((double) $this->value);
         $factor = round($value / $step) * $step;
         $delta = $value - $factor;
         if ($delta > 1.0E-5) {
             return array('number_step', $this->printName(), $this->step);
         }
     }
 }
Example #2
0
 public function check()
 {
     if ($error = parent::check()) {
         return $error;
     }
     foreach ($this->options as $opt) {
         if ($this->value == $opt->getValue()) {
             return;
         }
     }
     return array('should_choose', $this->printName());
 }
Example #3
0
 public function check()
 {
     if (!$this->required && !$this->value) {
         return;
     }
     if ($error = parent::check()) {
         return $error;
     }
     if (!filter_var($this->value, FILTER_VALIDATE_EMAIL)) {
         return array('bad_email', $this->printName());
     }
     return;
 }
Example #4
0
 public function check()
 {
     if ($error = parent::check()) {
         return $error;
     }
     if (!$this->required && $this->value == '') {
         return;
     } else {
         foreach ($this->options as $opt) {
             if ($this->multiple && in_array($opt->getValue(), $this->value) || !$this->multiple && $this->value == $opt->getValue()) {
                 return;
             }
         }
     }
     return array('should_choose', $this->printName());
 }