| @@ 19-33 (lines=15) @@ | ||
| 16 | /** |
|
| 17 | * Validator for max values. |
|
| 18 | */ |
|
| 19 | class Max implements ValidatorInterface { |
|
| 20 | ||
| 21 | /** |
|
| 22 | * {@inheritdoc} |
|
| 23 | */ |
|
| 24 | public function validate($value, array $parameters) { |
|
| 25 | ||
| 26 | if (count($parameters) !== 1) { |
|
| 27 | throw new ValidationException('"max" expects one parameter.'); |
|
| 28 | } |
|
| 29 | ||
| 30 | return $value === '' || $value === null || |
|
| 31 | (is_numeric($value) && $value <= $parameters[0]); |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| @@ 19-33 (lines=15) @@ | ||
| 16 | /** |
|
| 17 | * Validator for min values. |
|
| 18 | */ |
|
| 19 | class Min implements ValidatorInterface { |
|
| 20 | ||
| 21 | /** |
|
| 22 | * {@inheritdoc} |
|
| 23 | */ |
|
| 24 | public function validate($value, array $parameters) { |
|
| 25 | ||
| 26 | if (count($parameters) !== 1) { |
|
| 27 | throw new ValidationException('"min" expects one parameter.'); |
|
| 28 | } |
|
| 29 | ||
| 30 | return $value === '' || $value === null || |
|
| 31 | (is_numeric($value) && $value >= $parameters[0]); |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||