Skip to content

Commit 2badcbd

Browse files
author
苏青安
committed
fix: 修正 between 参数格式验证,更新为 'min,max' 格式
1 parent 91d087d commit 2badcbd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Rules/BetweenRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function validate(string $field, $value, $params = null): void
4040

4141
private function parseBetweenParams(string $params): array
4242
{
43-
if (preg_match('/^(-?\d+(?:\.\d+)?)-(-?\d+(?:\.\d+)?)$/', $params, $matches)) {
43+
if (preg_match('/^\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*$/', $params, $matches)) {
4444
return [(float)$matches[1], (float)$matches[2]];
4545
}
46-
throw new \InvalidArgumentException("between 参数格式错误,必须是 'min-max',例如:'-10--1' 或 '0.5-5.5'");
46+
throw new \InvalidArgumentException("between 参数格式错误,必须是 'min,max',例如:'-10,-1' 或 '0.5,5.5'");
4747
}
4848
}

0 commit comments

Comments
 (0)