diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 17ccd3f4cf09..93bc1cbf5ee5 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -1221,6 +1221,14 @@ protected function getSize($attribute, $value) protected function validateIn($attribute, $value, $parameters) { if (is_array($value) && $this->hasRule($attribute, 'Array')) { + + // Avoid performing validation on multi dimensional array + foreach ($value as $element) { + if (is_array($element)) { + return false; + } + } + return count(array_diff($value, $parameters)) == 0; } diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 4761f9b69293..ba6a934df7d1 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1135,6 +1135,9 @@ public function testValidateIn() $v = new Validator($trans, ['name' => ['foo', 'bar']], ['name' => 'Alpha|In:foo,bar']); $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['name' => ['foo', []]], ['name' => 'Array|In:foo,bar']); + $this->assertFalse($v->passes()); } public function testValidateNotIn()