mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
25 lines
895 B
PHP
25 lines
895 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
test('Scenario #1', catchMessages(
|
|
fn() => v::create()
|
|
->key('username', v::lengthBetween(2, 32))->key('birthdate', v::dateTime())
|
|
->key('password', v::notEmpty())
|
|
->key('email', v::email())
|
|
->assert(['username' => 'u', 'birthdate' => 'Not a date', 'password' => '']),
|
|
fn(array $messages) => expect($messages)->toBe([
|
|
'__root__' => '`["username": "u", "birthdate": "Not a date", "password": ""]` must pass all the rules',
|
|
'username' => 'The length of `.username` must be between 2 and 32',
|
|
'birthdate' => '`.birthdate` must be a valid date/time',
|
|
'password' => '`.password` must not be empty',
|
|
'email' => '`.email` must be present',
|
|
]),
|
|
));
|