Skip to content

Commit 2426184

Browse files
authored
Merge pull request #14 from consatan/fix/multiple_rules_in_field_valdation
fix: 一条规则多个验证器时验证结果错误
2 parents 5e1e643 + f3b58b0 commit 2426184

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Traits/MultipleRulesTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ protected function collectRules(): ?Generator
9090
$rules = is_array($rule[0]) ? $rule[0] : array_map('trim', explode('|', $rule[0]));
9191

9292
foreach ($rules as $aRule) {
93-
$rule = $this->parseRule($aRule, $rule);
94-
yield $field => $rule;
93+
yield $field => $this->parseRule($aRule, $rule);
9594
}
9695
}
9796
}

test/FieldValidationTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function testValidateField(): void
7676
$this->assertCount(3, $errors);
7777
$this->assertSame('freeTime is required!!!!', $v->getErrors('freeTime')[0]);
7878

79+
$v = FieldValidation::check($this->data, [
80+
['goods.pear', 'required|int|min:30|max:60']
81+
]);
82+
$this->assertTrue($v->isOk());
83+
7984
$v = FieldValidation::check($this->data, [
8085
['userId', 'required|int'],
8186
['userId', 'min:1'],

0 commit comments

Comments
 (0)