23 lines
723 B
TypeScript
23 lines
723 B
TypeScript
export function isValidPhone(phone: string): boolean {
|
||
return /^1\d{10}$/.test(phone.trim())
|
||
}
|
||
|
||
export function isValidSmsCode(code: string): boolean {
|
||
return /^\d{4,6}$/.test(code.trim())
|
||
}
|
||
|
||
export function isValidPassword(password: string): boolean {
|
||
return password.length >= 6 && password.length <= 32
|
||
}
|
||
|
||
/** 设置/修改登录密码:8-20 位,且字母、数字、符号至少包含 2 种 */
|
||
export function isValidStrongPassword(password: string): boolean {
|
||
const value = password.trim()
|
||
if (value.length < 8 || value.length > 20) return false
|
||
let types = 0
|
||
if (/[a-zA-Z]/.test(value)) types += 1
|
||
if (/\d/.test(value)) types += 1
|
||
if (/[^a-zA-Z0-9]/.test(value)) types += 1
|
||
return types >= 2
|
||
}
|