-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Validation. Fields with an asterisk. #5925
Conversation
Signed-off-by: Andrey Pyzhikov <[email protected]>
Thank you! |
I don't know how to correctly test this case. If you have suggestions or desires to take this PR from me, I will not mind) |
This PR is a bug fix. How did you write the fix? |
Signed-off-by: Andrey Pyzhikov <[email protected]>
I'm not sure about the test, but so far I can't think of anything else to check for a null value. |
@iRedds Thank you. |
@kenjis The test expects null to be passed to the processRules method if the key is not found. |
@kenjis // This code will throw a TypeError exception.
$this->validation->setRules(['a' => 'alpha'])->run(['a' => []]); Due to the strange behavior of the dot_array_search helper, the code below will also throw an exception. Because instead of null for a key not found, an array will be passed. // This code will throw a TypeError exception.
$this->validation->setRules(['a.b.c' => 'alpha'])->run(['a' => ['b' => []]]); |
Fixes #5922
Description
If the field contains a asterisk and is not found in the validation dataset, then
array_filter()
returns an empty array. This case is not handled, which may cause errors.So I suggest setting
$values = [$field => null]
if the field is not found.It also prevents a TypeError exception from being thrown if an array is passed to the function (rule) instead of a string. But this only applies to fields not found.