Skip to content

Commit

Permalink
Merge pull request #14 from consatan/fix/multiple_rules_in_field_vald…
Browse files Browse the repository at this point in the history
…ation

fix: 一条规则多个验证器时验证结果错误
  • Loading branch information
inhere committed Aug 20, 2019
2 parents 5e1e643 + f3b58b0 commit 2426184
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Traits/MultipleRulesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ protected function collectRules(): ?Generator
$rules = is_array($rule[0]) ? $rule[0] : array_map('trim', explode('|', $rule[0]));

foreach ($rules as $aRule) {
$rule = $this->parseRule($aRule, $rule);
yield $field => $rule;
yield $field => $this->parseRule($aRule, $rule);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/FieldValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public function testValidateField(): void
$this->assertCount(3, $errors);
$this->assertSame('freeTime is required!!!!', $v->getErrors('freeTime')[0]);

$v = FieldValidation::check($this->data, [
['goods.pear', 'required|int|min:30|max:60']
]);
$this->assertTrue($v->isOk());

$v = FieldValidation::check($this->data, [
['userId', 'required|int'],
['userId', 'min:1'],
Expand Down

0 comments on commit 2426184

Please sign in to comment.