Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ public function setRules(array $rules)
->mapWithKeys(function ($value, $key) {
return [str_replace('\.', '__dot__'.static::$placeholderHash, $key) => $value];
})
->dot()
->toArray();

$this->initialRules = $rules;
Expand Down
30 changes: 30 additions & 0 deletions tests/Foundation/FoundationFormRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ public function testValidatedMethodReturnsTheValidatedDataNestedArrayRules()
$this->assertEquals(['nested' => [['bar' => 'baz'], ['bar' => 'baz2']]], $request->validated());
}

public function testValidatedMethodReturnsTheValidatedDataNestedWildcardArrayRules()
{
$payload = ['nested' => [['bar' => 'baz', 'with' => 'extras'], ['bar' => 'baz2', 'with' => 'extras']]];

$request = $this->createRequest($payload, FoundationTestFormRequestNestedWildcardArrayStub::class);

$request->validateResolved();

$this->assertEquals(['nested' => [['bar' => 'baz'], ['bar' => 'baz2']]], $request->validated());
}

public function testValidatedMethodNotValidateTwice()
{
$payload = ['name' => 'specified', 'with' => 'extras'];
Expand Down Expand Up @@ -384,6 +395,25 @@ public function authorize()
}
}

class FoundationTestFormRequestNestedWildcardArrayStub extends FormRequest
{
public function rules()
{
return [
'nested' => [
'*' => [
'bar' => 'required',
],
],
];
}

public function authorize()
{
return true;
}
}

class FoundationTestFormRequestTwiceStub extends FormRequest
{
public static $count = 0;
Expand Down
Loading