diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 5d18ceba448f..283293f23b76 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -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; diff --git a/tests/Foundation/FoundationFormRequestTest.php b/tests/Foundation/FoundationFormRequestTest.php index 8827b8f92f66..bd22b2208cea 100644 --- a/tests/Foundation/FoundationFormRequestTest.php +++ b/tests/Foundation/FoundationFormRequestTest.php @@ -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']; @@ -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;