mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 06:12:17 +02:00
cc20a442a1
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
32 lines
569 B
PHP
32 lines
569 B
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
$arr = [
|
|
'name' => 'w',
|
|
'email' => 'hello@hello.com',
|
|
];
|
|
|
|
try {
|
|
v::create()
|
|
->key('name', v::length(2, 32))
|
|
->key('email', v::email())
|
|
->assert($arr);
|
|
} catch (NestedValidationException $e) {
|
|
print_r($e->getMessages());
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Array
|
|
(
|
|
[name] => name must have a length between 2 and 32
|
|
)
|