Skip to content

Commit 5bfb625

Browse files
committed
bug fixed for string validator. and some error method call in validation.
1 parent ab0c2c3 commit 5bfb625

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Utils/UserAndContextValidatorsTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function imageValidator($field, $suffixes = null)
331331
$mime = strtolower($imgInfo['mime']); // 支持不标准扩展名
332332

333333
// 是否是图片
334-
if (!\in_array($mime, Helper::IMG_MIME_TYPES, true)) {
334+
if (!\in_array($mime, Helper::$imgMimeTypes, true)) {
335335
return false;
336336
}
337337

@@ -403,12 +403,12 @@ public function compareValidator($val, $compareField)
403403

404404
public function sameValidator($val, $compareField)
405405
{
406-
return $this->compare($val, $compareField);
406+
return $this->compareValidator($val, $compareField);
407407
}
408408

409409
public function equalValidator($val, $compareField)
410410
{
411-
return $this->compare($val, $compareField);
411+
return $this->compareValidator($val, $compareField);
412412
}
413413

414414
/**

src/ValidationTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ protected function prepareRule(array $rule)
442442
case 'between':
443443
// fixed: 当只有 max 时,自动补充一个 min
444444
if (isset($rule['max']) && !isset($rule['min'])) {
445-
$rule['min'] = 0;
445+
$rule['min'] = PHP_INT_MIN;
446446
}
447447
break;
448448
}

tests/RuleValidationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testValidateString()
8383
'user_name' => $val
8484
], [
8585
['user_name', 'string', 'min' => 6],
86-
// ['user_name', 'string', 'max' => 16],
86+
['user_name', 'string', 'max' => 17],
8787
])->validate();
8888

8989
$this->assertTrue($v->passed());

0 commit comments

Comments
 (0)