All files / src/core verify.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 4/4
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43            10x 3x                 10x 2x 2x                 10x 2x 2x                 10x 2x 2x    
/**
 *
 * @ignore
 * @return {boolean} 判断是否是合法链接
 *
 */
export function verifyHttp(value: string): boolean {
  return /^http[s]?:\/\/.*/.test(value.trim())
}
 
/**
 *
 * @ignore
 * @return {boolean} 验证合法手机号
 *
 */
export function verifyMobile(mobile: string): boolean {
  const reg = /^1[3456789]\d{9}$/
  return reg.test(mobile.trim())
}
 
/**
 *
 * @ignore
 * @return {boolean} 判断验证码是否6位
 *
 */
export function verifyCode(code: string): boolean {
  const reg = /^\d{6}$/
  return reg.test(code)
}
 
/**
 *
 * @ignore
 * @return {boolean} 验证是否是合法邮箱格式
 *
 */
export function verifyEmail(email: string): boolean {
  const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  return re.test(email.trim())
}