You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RuoYi-Vue/ruoyi-ui-next/src/utils/validate.ts

35 lines
677 B

/**
* URL
*/
export function isExternal(path: string): boolean {
return /^(https?:|mailto:|tel:)/.test(path)
}
/**
*
*/
export function validUsername(str: string): boolean {
return str.trim().length >= 2
}
/**
*
*/
export function validPassword(str: string): boolean {
return str.length >= 5
}
/**
*
*/
export function isPhone(str: string): boolean {
return /^1[3-9]\d{9}$/.test(str)
}
/**
*
*/
export function isEmail(str: string): boolean {
return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(str)
}