Skip to content

Commit

Permalink
Fix: Model::getValidationRules() return when using shared rules
Browse files Browse the repository at this point in the history
This should fix #3039 .
  • Loading branch information
element-code authored May 27, 2020
1 parent b5e1941 commit df1938c
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 df1938c

Please sign in to comment.