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>
71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\AlphaException;
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::alpha()->check('aaa%a');
|
|
} catch (AlphaException $exception) {
|
|
echo $exception->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::alpha(' ')->check('bbb%b');
|
|
} catch (AlphaException $exception) {
|
|
echo $exception->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::alpha())->check('ccccc');
|
|
} catch (AlphaException $exception) {
|
|
echo $exception->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::alpha('% '))->check('ddd%d');
|
|
} catch (AlphaException $exception) {
|
|
echo $exception->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::alpha()->assert('eee^e');
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::alpha())->assert('fffff');
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::alpha('* &%')->assert('ggg^g');
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::alpha('^'))->assert('hhh^h');
|
|
} catch (NestedValidationException $exception) {
|
|
echo $exception->getFullMessage() . PHP_EOL;
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
"aaa%a" must contain only letters (a-z)
|
|
"bbb%b" must contain only letters (a-z) and " "
|
|
"ccccc" must not contain letters (a-z)
|
|
"ddd%d" must not contain letters (a-z) or "% "
|
|
- "eee^e" must contain only letters (a-z)
|
|
- "fffff" must not contain letters (a-z)
|
|
- "ggg^g" must contain only letters (a-z) and "* &%"
|
|
- "hhh^h" must not contain letters (a-z) or "^"
|