refactor: 提取正则和验证到 @vben/utils
This commit is contained in:
16
packages/utils/src/validator/validator.ts
Normal file
16
packages/utils/src/validator/validator.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { MOBILE_REGEX } from './regex';
|
||||
|
||||
/**
|
||||
* 验证是否为手机号码(中国)
|
||||
*
|
||||
* @param value 值
|
||||
* @returns 是否为手机号码(中国)
|
||||
*/
|
||||
function isMobile(value?: null | string): boolean {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
return MOBILE_REGEX.test(value);
|
||||
}
|
||||
|
||||
export { isMobile };
|
||||
Reference in New Issue
Block a user