validate.js
456 Bytes
/**
* @param {string} path
* @returns {Boolean}
*/
export function isExternal (path) {
return /^(https?:|mailto:|tel:)/.test(path)
}
export function validatePhone (rule, value, callback) {
let phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/
if (!value) {
return callback(new Error('号码不能为空!!'))
}
setTimeout(() => {
if (!phoneReg.test(value)) {
callback(new Error('格式有误'))
} else {
callback()
}
}, 100)
}