mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
3145426472
With that update, we will be fully following PSR-12. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
--CREDITS--
|
|
Bram Van der Sype <bram.vandersype@gmail.com>
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Exceptions\NotEmptyException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
try {
|
|
v::notEmpty()->check(null);
|
|
} catch (NotEmptyException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::notEmpty()->setName('Field')->check(null);
|
|
} catch (NotEmptyException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::notEmpty())->check(1);
|
|
} catch (NotEmptyException $e) {
|
|
echo $e->getMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::notEmpty()->assert('');
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::notEmpty()->setName('Field')->assert('');
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
v::not(v::notEmpty())->assert([1]);
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage() . PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
The value must not be empty
|
|
Field must not be empty
|
|
1 must be empty
|
|
- The value must not be empty
|
|
- Field must not be empty
|
|
- `{ 1 }` must be empty
|