respect-validation/tests/integration/rules/even.phpt
Henrique Moody cc20a442a1
Apply "SlevomatCodingStandard.TypeHints.DeclareStrictTypes"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:11:12 +01:00

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