// 网址校验
export const httpReg = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~/])+$/

export function validURL (url?:string) {
  const reg = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~/])+$/
  return reg.test(url||'')
}

// 手机校验
export const phoneReg = /^1[3456789]\d{9}$/ 

export const MobReg = /^((0\d{2,3})-)?(\d{7,8})$/

export function validPhone (phone: string) {
  return phoneReg.test(phone) || MobReg.test(phone)
}

// 邮箱校验
export const mailReg = /^[a-zA-Z0-9]+([._\\-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([._\\-]?[a-zA-Z0-9]+)*\.[a-zA-Z]{2,}$/

export function validMail (mail: string) {
  return mailReg.test(mail)
}
