respect-validation/tests/integration/keys_as_validator_names.phpt
Henrique Moody cc20a442a1
Apply "SlevomatCodingStandard.TypeHints.DeclareStrictTypes"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:11:12 +01:00

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