-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8129 from kenjis/fix-validation-dot-array-syntax
fix: Validation rule with `*` gets incorrect values as dot array syntax
- Loading branch information
Showing
8 changed files
with
161 additions
and
34 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
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,38 @@ | ||
<?php | ||
|
||
use Config\Services; | ||
|
||
$validation = Services::validation(); | ||
|
||
$data = [ | ||
'contacts' => [ | ||
'name' => 'Joe Smith', | ||
'just' => [ | ||
'friends' => [ | ||
['name' => 'SATO Taro'], | ||
['name' => 'Li Ming'], | ||
['name' => 'Heinz Müller'], | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$validation->setRules( | ||
['contacts.*.name' => 'required|max_length[8]'] | ||
); | ||
|
||
$validation->run($data); // false | ||
|
||
d($validation->getErrors()); | ||
/* | ||
Before: Captured `contacts.*.*.*.name` incorrectly. | ||
[ | ||
contacts.just.friends.0.name => "The contacts.*.name field cannot exceed 8 characters in length.", | ||
contacts.just.friends.2.name => "The contacts.*.name field cannot exceed 8 characters in length.", | ||
] | ||
After: Captures no data for `contacts.*.name`. | ||
[ | ||
contacts.*.name => string (38) "The contacts.*.name field is required.", | ||
] | ||
*/ |
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