-
Notifications
You must be signed in to change notification settings - Fork 770
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1915b6f
commit 75a2315
Showing
3 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (c) Alexandre Gomes Gaigalas <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
test('https://github.com/Respect/Validation/discussions/1427', expectAll( | ||
fn () => v::each( | ||
v::arrayVal() | ||
->key('groups', v::each(v::intVal())) | ||
->key('permissions', v::each(v::boolVal())) | ||
) | ||
->assert([ | ||
16 => [ | ||
'groups' => [1, 'A', 3, 4, 5], | ||
'permissions' => [ | ||
'perm1' => true, | ||
'perm2' => false, | ||
'perm3' => 'boom!', | ||
], | ||
], | ||
18 => false, | ||
24 => ['permissions' => false], | ||
]), | ||
'`.16.groups.1` must be an integer value', | ||
<<<'FULL_MESSAGE' | ||
- Each item in `[16: ["groups": [1, "A", 3, 4, 5], "permissions": ["perm1": true, "perm2": false, "perm3": "boom!"]], 18: false, ... ]` must be valid | ||
- `.16` must pass the rules | ||
- Each item in `.groups` must be valid | ||
- `.1` must be an integer value | ||
- Each item in `.permissions` must be valid | ||
- `.perm3` must be a boolean value | ||
- `.18` must pass all the rules | ||
- `.18` must be an array value | ||
- `.groups` must be present | ||
- `.permissions` must be present | ||
- `.24` must pass the rules | ||
- `.groups` must be present | ||
- `.permissions` must be iterable | ||
FULL_MESSAGE, | ||
[ | ||
'_self' => ['each' => 'Each item in `[16: ["groups": [1, "A", 3, 4, 5], "permissions": ["perm1": true, "perm2": false, "perm3": "boom!"]], 18: false, ... ]` must be valid'], | ||
'_children' => [ | ||
16 => [ | ||
'_self' => ['allOf' => '`["groups": [1, "A", 3, 4, 5], "permissions": ["perm1": true, "perm2": false, "perm3": "boom!"]]` must pass the rules'], | ||
'_children' => [ | ||
'groups' => [ | ||
'_self' => ['each' => 'Each item in `[1, "A", 3, 4, 5]` must be valid'], | ||
'_children' => [ | ||
1 => [ | ||
'_self' => ['intVal' => '"A" must be an integer value'], | ||
], | ||
], | ||
], | ||
'permissions' => [ | ||
'_self' => ['each' => 'Each item in `["perm1": true, "perm2": false, "perm3": "boom!"]` must be valid'], | ||
'_children' => [ | ||
'perm3' => [ | ||
'_self' => ['boolVal' => '"boom!" must be a boolean value'], | ||
], | ||
], | ||
], | ||
], | ||
], | ||
18 => [ | ||
'_self' => [ | ||
'allOf' => '`false` must pass all the rules', | ||
'arrayVal' => '`false` must be an array value', | ||
], | ||
'_children' => [ | ||
'groups' => [ | ||
'_self' => ['keyExists' => '`false` must be present'], | ||
], | ||
'permissions' => [ | ||
'_self' => ['keyExists' => '`false` must be present'], | ||
], | ||
], | ||
], | ||
24 => [ | ||
'_self' => [ | ||
'allOf' => '`["permissions": false]` must pass the rules', | ||
], | ||
'_children' => [ | ||
'groups' => [ | ||
'_self' => ['keyExists' => '`["permissions": false]` must be present'], | ||
], | ||
'permissions' => [ | ||
'_self' => ['each' => '`false` must be iterable'], | ||
], | ||
], | ||
], | ||
], | ||
] | ||
)); |