File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1688,8 +1688,8 @@ public function notBetween($value, $rule): bool
16881688
16891689 /**
16901690 * 验证数据长度
1691- * @param mixed $value 字段值
1692- * @param mixed $rule 验证规则
1691+ * @param mixed $value 字段值
1692+ * @param string|array|int|float $rule 验证规则
16931693 * @return bool
16941694 */
16951695 public function length ($ value , $ rule ): bool
@@ -1702,7 +1702,10 @@ public function length($value, $rule): bool
17021702 $ length = mb_strlen ((string ) $ value );
17031703 }
17041704
1705- if (is_string ($ rule ) && str_contains ($ rule , ', ' )) {
1705+ if (is_array ($ rule )) {
1706+ // 长度区间
1707+ return $ length >= $ rule [0 ] && $ length <= $ rule [1 ];
1708+ } elseif (is_string ($ rule ) && str_contains ($ rule , ', ' )) {
17061709 // 长度区间
17071710 [$ min , $ max ] = explode (', ' , $ rule );
17081711 return $ length >= $ min && $ length <= $ max ;
You can’t perform that action at this time.
0 commit comments