-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.2] Fix invalid() and valid() methods. (issue #14646) #14651
Conversation
Get updates from laravel
invalid() and valid() methods where returning empty arrays Issue link: #14646
Fixing style
@themsaid can you look at this? I can't follow what this is doing. |
Take a look at this test @taylorotwell public function testInvalidMethod()
{
$trans = $this->getRealTranslator();
$v = new Validator($trans,
[
['name' => 'John'],
['name' => null],
['name' => '']
],
[
'*.name' => 'required',
]);
$this->assertEquals($v->invalid(), [
1 => ['name' => null],
2 => ['name' => '']
]);
} The problem is with implicit attributes, currently to get the invalid attributes we do:
But in that case the data would look like:
While the messages array:
This will lead to no intersection between keys, resulting an empty array out of In the PR he's checking the key that comes before the first dot ( |
Exactly :) |
Maybe you need to add this test @xxnoobmanxx and provide something similar for public function testInvalidMethod()
{
$trans = $this->getRealTranslator();
$v = new Validator($trans,
[
['name' => 'John'],
['name' => null],
['name' => '']
],
[
'*.name' => 'required',
]);
$this->assertEquals($v->invalid(), [
1 => ['name' => null],
2 => ['name' => '']
]);
$v = new Validator($trans,
[
'name' => ''
],
[
'name' => 'required',
]);
$this->assertEquals($v->invalid(), [
'name' => ''
]);
} |
@themsaid Done. |
invalid()
andvalid()
methods where returning empty arrays when validating multi-dimensional data array