Files
api-client/src/utils/validate.js
2025-03-28 18:28:06 +08:00

54 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @author zxwk1998 不想保留author可删除
* @description 判读是否为外链
* @param path
* @returns {boolean}
*/
export function isExternal(path) {
return /^(https?:|mailto:|tel:)/.test(path)
}
/**
* @author https://github.com/zxwk1998/vue-admin-better 不想保留author可删除
* @description 校验密码是否小于6位
* @param str
* @returns {boolean}
*/
export function isPassword(str) {
return str.length >= 6
}
/**
* @author zxwk1998 不想保留author可删除
* @description 判断是否是字符串
* @param str
* @returns {boolean}
*/
export function isString(str) {
return typeof str === 'string' || str instanceof String
}
/**
* @author zxwk1998 不想保留author可删除
* @description 判断是否是数组
* @param arg
* @returns {arg is any[]|boolean}
*/
export function isArray(arg) {
if (typeof Array.isArray === 'undefined') {
return Object.prototype.toString.call(arg) === '[object Array]'
}
return Array.isArray(arg)
}
/**
* @author zxwk1998 不想保留author可删除
* @description 判断是否是手机号
* @param str
* @returns {boolean}
*/
export function isPhone(str) {
const reg = /^1\d{10}$/
return reg.test(str)
}