Skip to content

Commit

Permalink
Merge pull request #3040 from element-code/develop
Browse files Browse the repository at this point in the history
Fix: Model::getValidationRules() return when using shared rules
  • Loading branch information
lonnieezell authored May 31, 2020
2 parents fbe8343 + df1938c commit 1dfc79f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,9 @@ public function cleanRules(bool $choice = false)
*/
public function validate($data): bool
{
if ($this->skipValidation === true || empty($this->validationRules) || empty($data))
$rules = $this->getValidationRules();

if ($this->skipValidation === true || empty($rules) || empty($data))
{
return true;
}
Expand All @@ -1450,8 +1452,6 @@ public function validate($data): bool
$data = (array) $data;
}

$rules = $this->validationRules;

// ValidationRules can be either a string, which is the group name,
// or an array of rules.
if (is_string($rules))
Expand Down Expand Up @@ -1580,6 +1580,13 @@ protected function fillPlaceholders(array $rules, array $data): array
public function getValidationRules(array $options = []): array
{
$rules = $this->validationRules;

// ValidationRules can be either a string, which is the group name,
// or an array of rules.
if (is_string($rules))
{
$rules = $this->validation->loadRuleGroup($rules);
}

if (isset($options['except']))
{
Expand Down

0 comments on commit 1dfc79f

Please sign in to comment.