respect-validation/tests/integration/rules/minAge.phpt
Henrique Moody 3145426472
Update version of "respect/coding-standard"
With that update, we will be fully following PSR-12.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-07-21 22:54:41 +02:00

46 lines
1.1 KiB
PHP

--CREDITS--
Emmerson Siqueira <emmersonsiqueira@gmail.com>
Henrique Moody <henriquemoody@gmail.com>
--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
date_default_timezone_set('UTC');
use Respect\Validation\Exceptions\MinAgeException;
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v;
try {
v::minAge(18)->check('17 years ago');
} catch (MinAgeException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::not(v::minAge(18))->check('-30 years');
} catch (MinAgeException $exception) {
echo $exception->getMessage() . PHP_EOL;
}
try {
v::minAge(18)->assert('yesterday');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
try {
v::minAge(18, 'd/m/Y')->assert('12/10/2010');
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
?>
--EXPECT--
"17 years ago" must be 18 years or more
"-30 years" must not be 18 years or more
- "yesterday" must be 18 years or more
- "12/10/2010" must be 18 years or more