Files
yudao-ui-admin-vben/apps/web-ele/src/utils/validator.ts
2025-09-01 22:24:15 +08:00

19 lines
455 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 参数校验,对标 Hutool 的 Validator 工具类
// TODO @xingyu要不要抽到 package 里?
/** 手机号正则表达式(中国) */
const MOBILE_REGEX = /(?:0|86|\+86)?1[3-9]\d{9}/;
/**
* 验证是否为手机号码(中国)
*
* @param value 值
* @returns 是否为手机号码(中国)
*/
export function isMobile(value?: null | string): boolean {
if (!value) {
return false;
}
return MOBILE_REGEX.test(value);
}