2018-11-30 09:25:42 +01:00
|
|
|
--CREDITS--
|
|
|
|
Henrique Moody <henriquemoody@gmail.com>
|
2015-10-22 04:30:30 +02:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
2019-02-09 11:44:33 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2015-10-22 04:30:30 +02:00
|
|
|
require 'vendor/autoload.php';
|
|
|
|
|
2015-10-23 12:33:37 +02:00
|
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
2015-10-22 04:30:30 +02:00
|
|
|
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);
|
2015-10-23 12:33:37 +02:00
|
|
|
} catch (NestedValidationException $e) {
|
2015-10-22 04:30:30 +02:00
|
|
|
print_r($e->getMessages());
|
|
|
|
}
|
|
|
|
?>
|
2018-12-19 18:05:58 +01:00
|
|
|
--EXPECT--
|
2015-10-22 04:30:30 +02:00
|
|
|
Array
|
|
|
|
(
|
2018-03-07 19:07:52 +01:00
|
|
|
[name] => name must have a length between 2 and 32
|
2015-10-22 04:30:30 +02:00
|
|
|
)
|