feat: validate via regexp (#1877)

This commit is contained in:
joyqi
2025-05-12 23:40:38 +08:00
committed by GitHub
parent 917a763811
commit 5ef475b73f

View File

@@ -214,6 +214,18 @@ class Validate
return filter_var($str, FILTER_VALIDATE_INT) !== false;
}
/**
* 正则表达式验证
*
* @param string $str
* @param string $pattern
* @return bool
*/
public static function regexp(string $str, string $pattern): bool
{
return preg_match($pattern, $str) === 1;
}
/**
* 增加验证规则
*