Blame view

ant-design-vue-jeecg/src/utils/validate.js 475 Bytes
肖超群 authored
1
2
3
4
/**
 * 邮箱
 * @param {*} s
 */
肖超群 authored
5
export function isEmail(s) {
肖超群 authored
6
7
8
9
10
11
12
  return /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s)
}

/**
 * 手机号码
 * @param {*} s
 */
肖超群 authored
13
export function isMobile(s) {
肖超群 authored
14
15
16
17
18
19
20
  return /^1[0-9]{10}$/.test(s)
}

/**
 * 电话号码
 * @param {*} s
 */
肖超群 authored
21
export function isPhone(s) {
肖超群 authored
22
23
24
25
26
27
28
  return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s)
}

/**
 * URL地址
 * @param {*} s
 */
肖超群 authored
29
export function isURL(s) {
肖超群 authored
30
31
  return /^http[s]?:\/\/.*/.test(s)
}