mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 07:15:45 +01:00
43 lines
910 B
PHP
43 lines
910 B
PHP
--CREDITS--
|
|
Paul Karikari <paulkarikari1@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\EvenException;
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::even()->check(-1);
|
|
} catch (EvenException $exception) {
|
|
echo $exception->getMessage().PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::even()->assert(5);
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage().PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::even())->check(6);
|
|
} catch (EvenException $exception) {
|
|
echo $exception->getMessage().PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::even())->assert(8);
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage().PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
-1 must be an even number
|
|
- 5 must be an even number
|
|
6 must not be an even number
|
|
- 8 must not be an even number
|