Appearance
super-tools-lib - v1.74.0 / Modules / reg
Module: reg
Table of contents
Variables
Functions
Variables
reg
• Const
reg: Object
Type declaration
Name | Type | Description |
---|---|---|
arr | RegExp | 校验路径中是否存在数组,[] |
cP | RegExp | 身份证 |
cPattern | RegExp | 车牌号 |
character | RegExp | - |
chinese10 | RegExp | 匹配:中文 1~10个中文 |
chinese_and_english | RegExp | 匹配:汉字,a-z,A-Z |
chinese_numeric_letters | RegExp | 数字,字母,汉字,任意组合 |
cname | RegExp | 校验中文姓名 |
color16Reg | RegExp | 16进制颜色校验 |
email | RegExp | 邮箱 |
ename | RegExp | 校验英文名 每一个单词首字母都是大写 |
intNumber | RegExp | 正整数 |
ip | RegExp | 校验IP地址 |
ipv4 | RegExp | 校验ipv4 |
isNotNegativeFloatNum | RegExp | 匹配非负浮点数 |
mac | RegExp | 校验mac地址是否正确 |
mobile | RegExp | 手机号 |
negativeInteger | RegExp | 负整数 |
nickname | RegExp | - |
number | RegExp | 数字0~30 |
numeric_letters | RegExp | 数字,字母,数字或字母,字母或数字组合 |
phone | RegExp | 手机号 |
positiveInt3_decimal2 | RegExp | 正整数最多输入3位,小数最多输入2位 |
positiveInt5 | RegExp | 正整数 1~5 |
strong_password | RegExp | 密码强度正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符 |
verify_code | RegExp | - |
verify_pwd | RegExp | - |
website | RegExp | 网址 |
Functions
validate
▸ validate(key
, value
): boolean
验证内容
- 规则key集合
- mobile 手机号
- chinese_and_english 匹配:汉字,a-z,A-Z
- chinese10 匹配:中文 1~10个中文
- website 网址
- email 邮箱
- character 字符0~254
- intNumber 正整数
- positiveInt5 正整数 1~5
- positiveInt3_decimal2 正整数最多输入3位,小数最多输入2位
- negativeInteger 负整数
- isNotNegativeFloatNum 匹配非负浮点数
- cP 身份证
- cPattern 车牌号
- number 数字0~30
- numeric_letters 数字,字母,数字或字母,字母或数字组合
- chinese_numeric_letters 数字,字母,汉字,任意组合
- strong_password 密码强度正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
- cname 校验中文姓名
- ename 校验英文名 每一个单词首字母都是大写
- ip 校验IP地址
- ipv4 校验ipv4
- color16Reg 16进制颜色校验
- mac 校验mac地址是否正确
- arr 校验路径中是否存在数组,[]
Since
1.62.0
Example
ts
import { validate } from 'super-tools-lib'
validate('cname', 1) // false
Parameters
Name | Type | Description |
---|---|---|
key | "number" | "mobile" | "phone" | "chinese_and_english" | "chinese10" | "website" | "nickname" | "verify_code" | "verify_pwd" | "email" | "character" | "intNumber" | "positiveInt5" | "positiveInt3_decimal2" | "negativeInteger" | "isNotNegativeFloatNum" | "cP" | "cPattern" | "numeric_letters" | "chinese_numeric_letters" | "strong_password" | "cname" | "ename" | "ip" | "ipv4" | "color16Reg" | "mac" | "arr" | 规则 |
value | string | 校验的内容 |
Returns
boolean
返回是否符合规则 true | false