depage-forms v1.4.1
html forms made easy
Loading...
Searching...
No Matches
Validators/Number.php
Go to the documentation of this file.
1<?php
2
7
8namespace Depage\HtmlForm\Validators;
9
13class Number extends Validator
14{
22 public function validate($value, $parameters = [])
23 {
24 $min = isset($parameters['min']) ? $parameters['min'] : null;
25 $max = isset($parameters['max']) ? $parameters['max'] : null;
26
27 return is_numeric($value)
28 && (($value >= $min) || ($min === null))
29 && (($value <= $max) || ($max === null));
30 }
31}
default validator for number input elements
validate($value, $parameters=[])
number validation