校验器

# 方法列表

方法名 说明 参数 返回值
$AsIsEmail 校验是否满足邮箱格式 String类型 Boolean类型
$AsIsMobileNumber 校验是否满足手机号码格式 String类型 Boolean类型
$AsIsPhoneNumber 校验是否满足电话号码格式 String类型 Boolean类型
$AsIsURL 校验是否满足url格式 String类型 Boolean类型
$AsIsString 校验是否是字符串类型 任意类型 Boolean类型
$AsIsNumber 校验是否是数字类型 任意类型 Boolean类型
$AsIsBoolean 校验是否是布尔类型 任意类型 Boolean类型
$AsIsFunction 校验是否是函数类型 任意类型 Boolean类型
$AsIsNull 校验是否是null 任意类型 Boolean类型
$AsIsUndefined 校验是否是undefined 任意类型 Boolean类型
$AsIsObj 校验是否是对象类型 任意类型 Boolean类型
$AsIsArray 校验是否是数组类型 任意类型 Boolean类型
$AsIsDate 校验是否是日期类型 任意类型 Boolean类型
$AsIsRegExp 校验是否是正则表达式 任意类型 Boolean类型
$AsIsError 校验是否是错误类型 任意类型 Boolean类型
$AsIsSymbol 校验是否是Symbol类型 任意类型 Boolean类型
$AsIsPromise 校验是否是Promise类型 任意类型 Boolean类型
$AsIsSet 校验是否是集合 任意类型 Boolean类型
$AsIsWeiXinBrowser 校验是否是微信环境 Boolean类型
$AsIsDeviceMobile 校验是否是移动设备 Boolean类型
$AsIsQQBrowser 校验是否是QQ浏览器 Boolean类型
$AsIsSpider 校验是否是爬虫 Boolean类型
$AsIsIOS 校验是否是IOS环境 Boolean类型
$AsIsPC 校验是否是PC端 Boolean类型
$AsIsCardID 校验是否满足严格的身份证格式要求 String类型 Boolean类型
$AsHaveCNChars 校验是否含有中文字 String类型 Boolean类型
$AsIsEmojiCharacter 校验是否含有表情 String类型 Boolean类型
$AsGetUrlState 校验是否是有效的url String类型 Boolean类型
$AsCheckIpAddress 校验是否是IP格式 String类型 Boolean类型

# 简单示例

//测试邮箱
console.log(this.$AsIsEmail("123"))//false
console.log(this.$AsIsEmail("145@qq.com"))//true
//校验手机号
console.log(this.$AsIsMobileNumber("132891234"))//false
console.log(this.$AsIsMobileNumber("13225618912"))//true
//校验电话号码
console.log(this.$AsIsPhoneNumber("1239"))//false
console.log(this.$AsIsPhoneNumber("7348123"))//true
// 是否url地址
console.log(this.$AsIsURL("1239"))//false
console.log(this.$AsIsURL("http"))//false
console.log(this.$AsIsURL("127.3.12.1"))//false
console.log(this.$AsIsURL("https://baidu.com"))//true
// 是否字符串
console.log(this.$AsIsString("1"))//true
console.log(this.$AsIsString(1))//false
// 是否数字
console.log(this.$AsIsNumber("1"))//false
console.log(this.$AsIsNumber(1))//true
// 是否boolean
console.log(this.$AsIsBoolean("1"))//false
console.log(this.$AsIsBoolean(false))//true
// 是否函数
console.log(this.$AsIsFunction("1"))//false
console.log(this.$AsIsFunction(function () {
}))//true
// 是否为null
console.log(this.$AsIsNull(undefined))//false
console.log(this.$AsIsNull(null))//true
// 是否undefined
console.log(this.$AsIsUndefined(undefined))//true
console.log(this.$AsIsUndefined(null))//false
// 是否对象
console.log(this.$AsIsObj({}))//true
console.log(this.$AsIsObj(1))//false
console.log(this.$AsIsObj([]))//false
// 是否数组
console.log(this.$AsIsArray({}))//false
console.log(this.$AsIsArray(1))//false
console.log(this.$AsIsArray([]))//true
// 是否时间
let now = new Date();
let nowTime = new Date().getTime();
console.log(this.$AsIsDate(now))//true
console.log(this.$AsIsDate(nowTime))//false
console.log(this.$AsIsDate(111))//false
// 是否正则
console.log(this.$AsIsRegExp("2222"))//false
console.log(this.$AsIsRegExp(/^([0-9]{3,4}-)?[0-9]{7,8}$/))//true
// 是否错误对象
let errorObj = new Error("这是一个错误");
console.log(this.$AsIsError("2222"))//false
console.log(this.$AsIsError(errorObj))//true
// 是否Symbol函数
let mySymbol = Symbol('mySymbolDescription');
console.log(this.$AsIsSymbol("2222"))//false
console.log(this.$AsIsSymbol(mySymbol))//true
// 是否Promise对象
let myPromise = new Promise((resolve, reject) => {
});
console.log(this.$AsIsPromise("2222"))//false
console.log(this.$AsIsPromise(myPromise))//true
// 是否Set对象
let mySet = new Set();
console.log(this.$AsIsSet("2222"))//false
console.log(this.$AsIsSet(mySet))//true
// isWeiXinBrowser
console.log(this.$AsIsWeiXinBrowser())
// 是否是移动端
console.log(this.$AsIsDeviceMobile())
// 是否是QQ浏览器
console.log(this.$AsIsQQBrowser())
// 是否是爬虫
console.log(this.$AsIsSpider())
// 是否ios
console.log(this.$AsIsIOS())
// 是否为PC端
console.log(this.$AsIsPC())
// 严格的身份证校验
console.log(this.$AsIsCardID("31123131292921912"))//false
console.log(this.$AsIsCardID("421126199908127212"))//true
//校验是否包含中文
console.log(this.$AsHaveCNChars("31123131292921912"))//false
console.log(this.$AsHaveCNChars("哈哈哈11"))//true