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>
31 lines
775 B
PHP
31 lines
775 B
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--TEST--
|
|
keys as validator names
|
|
--FILE--
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\NestedValidationException;
|
|
use Respect\Validation\Validator;
|
|
|
|
try {
|
|
Validator::create()
|
|
->key('username', Validator::length(2, 32))
|
|
->key('birthdate', Validator::dateTime())
|
|
->setName('User Subscription Form')
|
|
->assert(['username' => '0', 'birthdate' => 'Whatever']);
|
|
} catch (NestedValidationException $e) {
|
|
echo $e->getFullMessage();
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
- All of the required rules must pass for User Subscription Form
|
|
- username must have a length between 2 and 32
|
|
- birthdate must be a valid date/time
|