validators/number.php
Go to the documentation of this file.
1 <?php
7 namespace depage\htmlform\validators;
8 
12 class number extends validator
13 {
21  public function validate($value, $parameters = array())
22  {
23  $min = isset($parameters['min']) ? $parameters['min'] : null;
24  $max = isset($parameters['max']) ? $parameters['max'] : null;
25 
26  return is_numeric($value)
27  && (($value >= $min) || ($min === null))
28  && (($value <= $max) || ($max === null));
29  }
30 }
validate($value, $parameters=array())
number validation
default validator for number input elements
parent validator class
Definition: validator.php:14