diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 274c7cf0f252..3107533b674d 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -527,6 +527,22 @@ protected function validateAttribute($attribute, $rule) } } + /** + * Generate a key map to determine the valid + * and invalid data + * @return array + */ + protected function getMessagesKeyMap() + { + $map = []; + + foreach($this->messages()->toArray() as $key => $message){ + $map []= explode('.', $key)[0]; + } + + return array_flip(array_unique($map)); + } + /** * Returns the data which was valid. * @@ -538,7 +554,7 @@ public function valid() $this->passes(); } - return array_diff_key($this->data, $this->messages()->toArray()); + return array_diff_key($this->data, $this->getMessagesKeyMap()); } /** @@ -552,7 +568,7 @@ public function invalid() $this->passes(); } - return array_intersect_key($this->data, $this->messages()->toArray()); + return array_intersect_key($this->data, $this->getMessagesKeyMap()); } /**