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>
46 lines
1.1 KiB
PHP
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
|