Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from laravel-ardent/crash-getValidationRule
Browse files Browse the repository at this point in the history
bug: getValidationRule crash on field without rule
  • Loading branch information
igorsantos07 committed Jan 20, 2016
2 parents 2c64b5e + 57e5eb9 commit 43bc539
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Laravalid/Converter/Base/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}
}

/**
Expand Down Expand Up @@ -222,4 +225,4 @@ protected function getDefaultErrorMessage($laravelRule, $attribute)

return ['data-msg-'.$laravelRule => $message];
}
}
}

0 comments on commit 43bc539

Please sign in to comment.