diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index db37ba8372bb..b7bc47a1bca5 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -255,11 +255,8 @@ protected function hydrateFiles(array $data, $arrayKey = null) // we use to conveniently separate out these files from other data. if ($value instanceof File) { $this->files[$newKey] = $value; - - unset($data[$key]); } elseif (is_array($value) && ! empty($value) && empty($this->hydrateFiles($value, $newKey))) { - unset($data[$key]); } } diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 9de505c418b9..b8c21cf5f897 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -564,7 +564,9 @@ public function testValidateRequired() $foo = new File(__FILE__, false); $v = new Validator($trans, ['name' => [$file, $foo]], ['name.0' => 'Required', 'name.1' => 'Required']); $this->assertTrue($v->passes()); - $this->assertEmpty($v->getData()); + + $v = new Validator($trans, ['files' => [$file, $foo]], ['files' => 'Required']); + $this->assertTrue($v->passes()); } public function testValidateRequiredWith() @@ -3227,7 +3229,7 @@ public function testFilesHydration() $file = new File(__FILE__, false); $v = new Validator($trans, ['file' => $file, 'text' => 'text'], ['text' => 'Required']); $this->assertEquals(['file' => $file], $v->getFiles()); - $this->assertEquals(['text' => 'text'], $v->getData()); + $this->assertEquals(['text' => 'text', 'file' => $file], $v->getData()); } public function testArrayOfFilesHydration() @@ -3237,7 +3239,7 @@ public function testArrayOfFilesHydration() $file2 = new File(__FILE__, false); $v = new Validator($trans, ['file' => [$file, $file2], 'text' => 'text'], ['text' => 'Required']); $this->assertEquals(['file.0' => $file, 'file.1' => $file2], $v->getFiles()); - $this->assertEquals(['text' => 'text'], $v->getData()); + $this->assertEquals(['text' => 'text', 'file' => [$file, $file2]], $v->getData()); } public function testMultipleFileUploads()