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

Commit 43bc539

Browse files
committed
Merge pull request #1 from laravel-ardent/crash-getValidationRule
bug: getValidationRule crash on field without rule
2 parents 2c64b5e + 57e5eb9 commit 43bc539

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Laravalid/Converter/Base/Converter.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ public function getValidationRules()
129129
*/
130130
public function getValidationRule($inputName)
131131
{
132-
return is_array($this->getValidationRules()[$inputName])?
133-
$this->getValidationRules()[$inputName] :
134-
explode('|', $this->getValidationRules()[$inputName]);
132+
$rules = $this->getValidationRules();
133+
if (isset($rules[$inputName])) {
134+
return is_array($rules[$inputName])? $rules[$inputName] : explode('|', $rules[$inputName]);
135+
} else {
136+
return [];
137+
}
135138
}
136139

137140
/**
@@ -222,4 +225,4 @@ protected function getDefaultErrorMessage($laravelRule, $attribute)
222225

223226
return ['data-msg-'.$laravelRule => $message];
224227
}
225-
}
228+
}

0 commit comments

Comments
 (0)