finance-pay-admin/pc/utils/validate.ts

51 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2023-11-08 18:02:55 +08:00
export {
isArray,
isBoolean,
isDate,
isObject,
isFunction,
isString,
isNumber,
isNull
} from 'lodash-es'
import { isObject } from 'lodash-es'
/**
* @description http
*/
export function isExternal(path: string) {
return /^(https?:|mailto:|tel:)/.test(path)
}
/**
* @description http
*/
export const isLinkHttp = (link: string): boolean =>
/^(https?:)?\/\//.test(link)
/**
* @description
*/
export const isLinkTel = (link: string): boolean => /^tel:/.test(link)
/**
* @description
*/
export const isLinkMailto = (link: string): boolean => /^mailto:/.test(link)
/**
* @description
* @param {unknown} value
* @return {Boolean}
*/
export const isEmpty = (value: unknown) => {
return value !== null && value !== '' && typeof value !== 'undefined'
}
/**
* @description
* @param {Object} value
* @return {Boolean}
*/
export const isEmptyObject = (target: object) => {
return isObject(target) && !Object.keys(target).length
}