Skip to content

Commit 80afc6e

Browse files
committed
perf: 移除未用到的示例工具函数
1 parent d47428c commit 80afc6e

File tree

1 file changed

+0
-66
lines changed

1 file changed

+0
-66
lines changed

src/utils/validate.ts

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,69 +13,3 @@ export function isExternal(path: string) {
1313
const reg = /^(https?:|mailto:|tel:)/
1414
return reg.test(path)
1515
}
16-
17-
/** 判断是否为网址(带协议) */
18-
export function isUrl(url: string) {
19-
const reg = /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{1,64})?\.)+[a-z]{2,6}\/?/
20-
return reg.test(url)
21-
}
22-
23-
/** 判断是否为网址或 IP(带端口) */
24-
export function isUrlPort(url: string) {
25-
const reg = /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/
26-
return reg.test(url)
27-
}
28-
29-
/** 判断是否为域名(不带协议) */
30-
export function isDomain(domain: string) {
31-
const reg = /^([0-9a-z-]+\.)+([a-z]{2,})$/i
32-
return reg.test(domain)
33-
}
34-
35-
/** 判断版本号格式是否为 X.Y.Z */
36-
export function isVersion(version: string) {
37-
const reg = /^\d+(?:\.\d+){2}$/
38-
return reg.test(version)
39-
}
40-
41-
/** 判断时间格式是否为 24 小时制(HH:mm:ss) */
42-
export function is24H(time: string) {
43-
const reg = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
44-
return reg.test(time)
45-
}
46-
47-
/** 判断是否为手机号(1 开头) */
48-
export function isPhoneNumber(str: string) {
49-
const reg = /^(?:(?:\+|00)86)?1\d{10}$/
50-
return reg.test(str)
51-
}
52-
53-
/** 判断是否为第二代身份证(18 位) */
54-
export function isChineseIdCard(str: string) {
55-
const reg = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[12]\d|30|31)\d{3}[\dX]$/i
56-
return reg.test(str)
57-
}
58-
59-
/** 判断是否为 Email(支持中文邮箱) */
60-
export function isEmail(email: string) {
61-
const reg = /^[A-Z0-9\u4E00-\u9FA5]+@[\w-]+(\.[\w-]+)+$/i
62-
return reg.test(email)
63-
}
64-
65-
/** 判断是否为 MAC 地址 */
66-
export function isMAC(mac: string) {
67-
const reg = /^(([a-f0-9][0,2468ace]:([a-f0-9]{2}:){4})|([a-f0-9][0,2468ace]-([a-f0-9]{2}-){4}))[a-f0-9]{2}$/i
68-
return reg.test(mac)
69-
}
70-
71-
/** 判断是否为 IPv4 地址 */
72-
export function isIPv4(ip: string) {
73-
const reg = /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:\d|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5]))?$/
74-
return reg.test(ip)
75-
}
76-
77-
/** 判断是否为车牌(兼容新能源车牌) */
78-
export function isLicensePlate(str: string) {
79-
const reg = /^[使][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9]$/
80-
return reg.test(str)
81-
}

0 commit comments

Comments
 (0)