Skip to content
On this page

super-tools-lib - v1.74.0 / Modules / reg

Module: reg

Table of contents

Variables

Functions

Variables

reg

Const reg: Object

Type declaration

NameTypeDescription
arrRegExp校验路径中是否存在数组,[]
cPRegExp身份证
cPatternRegExp车牌号
characterRegExp-
chinese10RegExp匹配:中文 1~10个中文
chinese_and_englishRegExp匹配:汉字,a-z,A-Z
chinese_numeric_lettersRegExp数字,字母,汉字,任意组合
cnameRegExp校验中文姓名
color16RegRegExp16进制颜色校验
emailRegExp邮箱
enameRegExp校验英文名 每一个单词首字母都是大写
intNumberRegExp正整数
ipRegExp校验IP地址
ipv4RegExp校验ipv4
isNotNegativeFloatNumRegExp匹配非负浮点数
macRegExp校验mac地址是否正确
mobileRegExp手机号
negativeIntegerRegExp负整数
nicknameRegExp-
numberRegExp数字0~30
numeric_lettersRegExp数字,字母,数字或字母,字母或数字组合
phoneRegExp手机号
positiveInt3_decimal2RegExp正整数最多输入3位,小数最多输入2位
positiveInt5RegExp正整数 1~5
strong_passwordRegExp密码强度正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
verify_codeRegExp-
verify_pwdRegExp-
websiteRegExp网址

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

NameTypeDescription
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"规则
valuestring校验的内容

Returns

boolean

返回是否符合规则 true | false