From 57e5eb95190c1de628199b7de935db7772a9c15a Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Wed, 20 Jan 2016 15:25:40 -0200 Subject: [PATCH] bug: getValidationRule crash on field without rule --- src/Laravalid/Converter/Base/Converter.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Laravalid/Converter/Base/Converter.php b/src/Laravalid/Converter/Base/Converter.php index 814a92f..05fdc89 100644 --- a/src/Laravalid/Converter/Base/Converter.php +++ b/src/Laravalid/Converter/Base/Converter.php @@ -129,9 +129,12 @@ public function getValidationRules() */ public function getValidationRule($inputName) { - return is_array($this->getValidationRules()[$inputName])? - $this->getValidationRules()[$inputName] : - explode('|', $this->getValidationRules()[$inputName]); + $rules = $this->getValidationRules(); + if (isset($rules[$inputName])) { + return is_array($rules[$inputName])? $rules[$inputName] : explode('|', $rules[$inputName]); + } else { + return []; + } } /** @@ -222,4 +225,4 @@ protected function getDefaultErrorMessage($laravelRule, $attribute) return ['data-msg-'.$laravelRule => $message]; } -} \ No newline at end of file +}