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 sometimes validation for nested arrays #4076
Fix sometimes validation for nested arrays #4076
Conversation
Need more examples of what this fixes. Paste something that was broken before and is now fixed. Also there are spacing problems in this pull. |
The issue came up here: http://stackoverflow.com/questions/22892058/laravel-sometimes-validator-fails-with-nested-arrays Imagine form with array data: Then: Validator::make($data, $rules)->passes(); // false BUT Validator::make($data, $rules)->passes(); // true Validator checking optional rule can't get to the nested array and find proper key, thus returns always true. Check the tests, you'll find example there. About spacing - there were indents with spaces, but in latest push there are tabs. |
Although previous solution worked, it was overkill. In fact one tiny fix in Validator - using array_dot, solves the issue. |
@@ -307,7 +307,7 @@ protected function getValue($attribute) | |||
protected function isValidatable($rule, $attribute, $value) | |||
{ | |||
return $this->presentOrRuleIsImplicit($rule, $attribute, $value) && | |||
$this->passesOptionalCheck($attribute); | |||
$this->passesOptionalCheck($attribute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is still wrong here.
Also, please squash this when you are done. 7 commits or more will be a bit much. :) |
Squashed, indentations corrected. Check it now please. |
👍 from me. |
this definitely should be included in public release |
Also is worth noting that documentation is wrong about $v = Validator::make($data, array(
'email' => 'sometimes|required|email',
)); Clearly here $v = Validator::make($data, array(
'email' => 'sometimes|email',
)); |
…idation-for-nested-arrays Fix sometimes validation for nested arrays
Fixes not working 'sometimes' optional check for nested arrays.