src/Valdi/Validator/Comparator.php 1 location
|
@@ 37-45 (lines=9) @@
|
| 34 |
|
/** |
| 35 |
|
* {@inheritdoc} |
| 36 |
|
*/ |
| 37 |
|
public function validate($value, array $parameters) { |
| 38 |
|
|
| 39 |
|
if (count($parameters) !== 1) { |
| 40 |
|
throw new ValidationException('"max" expects one parameter.'); |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
return in_array($value, array('', null), true) || |
| 44 |
|
(is_numeric($value) && $this->compare($value, $parameters[0])); |
| 45 |
|
} |
| 46 |
|
} |
| 47 |
|
|
src/Valdi/Validator/InSet.php 1 location
|
@@ 24-30 (lines=7) @@
|
| 21 |
|
/** |
| 22 |
|
* {@inheritdoc} |
| 23 |
|
*/ |
| 24 |
|
public function validate($value, array $parameters) { |
| 25 |
|
if (count($parameters) === 0) { |
| 26 |
|
throw new ValidationException('"set" expects at least one parameter.'); |
| 27 |
|
} |
| 28 |
|
return in_array($value, array('', null), true) || |
| 29 |
|
in_array($value, $parameters); |
| 30 |
|
} |
| 31 |
|
} |
| 32 |
|
|