feat: validate via regexp (#1877)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加验证规则
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user