mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
With that update, we will be fully following PSR-12. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
44 lines
970 B
PHP
44 lines
970 B
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\BetweenException;
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::between(1, 2)->check(0);
|
|
} catch (BetweenException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::between('yesterday', 'tomorrow'))->check('today');
|
|
} catch (BetweenException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::between('a', 'c')->assert('d');
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::between(-INF, INF))->assert(0);
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
0 must be between 1 and 2
|
|
"today" must not be between "yesterday" and "tomorrow"
|
|
- "d" must be between "a" and "c"
|
|
- 0 must not be between `-INF` and `INF`
|