/** * 中文字符校验 * @description 中文字符, 只要是汉字即可(只能有中文),默认最少1个, 常用于真实姓名校验 * @param { string } str 中文字符 * @param { number } maxLen 中文字符最大位数 * @return boolean * **/ declare function chineseReg(str: string, maxLen?: number): boolean; /** * 字母字符校验 * @description 字母字符, 只要是字母即可(只能有大小写字母),默认最少5个,可能用到英文名字校验 * @param { string } str 英文字符 * @param { number } maxLen 字母字符最大位数 * @return boolean * **/ declare function letterReg(str: string, maxLen?: number): boolean; /** * 大写英文字符校验 * @description 大写英文字符,只要是大写字母即可(只能有大写字母) * @param { string } str 需要验证的字符串 * @param { number } maxLen 大写字母字符最大位数 * **/ declare function upperLetterReg(str: string, maxLen?: number): boolean; /** * 小写英文字符校验 * @description 小写英文字符,只要是小写字母即可(只能有小写字母) * @param { string } str 需要验证的字符串 * @param { number } maxLen 小写字母字符最大位数 * **/ declare function lowerLetterReg(str: string, maxLen?: number): boolean; /** * 字母+数字字符校验 * @description 字母+数字字符, 只要是字母和数字即可(只能有大小写字母和数字) * @param { string } str 英文数字字符 * @param { number } maxLen 字符最大位数 * **/ declare function letterNumberReg(str: string, maxLen?: number): boolean; /** * 汉字、字母、数字字符 * @description 中文、英文、数字字符, 只要是中文、英文、数字即可 * @param { string } str 字符串 @param { number } maxLen 字符最大位数 * **/ declare function letterZhNumberReg(str: string, maxLen?: number): boolean; /** * 所有格式字符校验 * @description 所有格式字符,包含空白字符 默认最少1个,暂时不知道用于什么场景 * @param { string } str 需要校验的字符串 * @param { number } maxLen 字符最大位数 * * **/ declare function allStrReg(str: string, maxLen?: number): boolean; /** * 特殊字符校验 * @description 特殊字符,包含空白字符 默认最少1个,暂时不知道用于什么场景 * @param { string } str 需要校验的字符串 * @param { string } scope 可指定特殊字符,默认 !@#$%^&*()_+-=[]{}|;':",./<>? * * **/ declare function specialStrReg(str: string, scope?: string): boolean; /** * 自定义字符范围校验 * @description 自定义字符范围校验,可以指定自定义字符范围及长度 * @param { string } str 需要校验的字符串 * @param { string } scope 自定义字符范围 * @param { [ number, number ] } lens 可指定自定义字符范围的长度范围 * **/ declare function customStrReg(str: string, scope: string, lens?: [number, number]): boolean; /** * 常规邮箱格式校验 * @description `gaozihang-001@gmail.com` 只允许英文字母、数字、下划线、英文句号、以及中划线组成 * @param { string } email 邮箱 * @param { boolean } isHaveChinese 是否允许中文 ( 名称允许汉字, 域名只允许英文域名 ) * @return boolean * **/ declare function generalEmailReg(email: string, isHaveChinese?: boolean): boolean; /** * 宽松手机号校验 * @description 手机号(mobile phone)中国(宽松), 只要是13,14,15,16,17,18,19开头即可 * @param { string } mobile 手机号 * @param { `${number}-${number}` } scope 'min-max' 可指定手机号第二位的数字范围 默认为 0-9 * @returns boolean * **/ declare function loosePhoneReg(mobile: string, scope?: `${number}-${number}`): boolean; /** * 严格手机号校验 * @description 手机号(mobile phone)中国(严谨), 根据工信部2019年最新公布的手机号段,支持已+86、+086开头的手机号 * @param { string } mobile 手机号 * @param { boolean } isArea 是否加上区号验证,默认为true * @returns boolean * **/ declare function strictPhoneReg(mobile: string, isArea?: boolean): boolean; /** * 国内固定电话号码校验 051-4405222、0211-87888822 * @description 固定电话号码(telephone number)中国, 只要是区号+号码(3+{7,8}、4+{7,8})组成即可 * @param { string } tel 固定电话号码 * @param { boolean } isExtension 是否需要分机号码 * @return boolean * **/ declare function chinaTelPhoneReg(tel: string, isExtension?: boolean): boolean; /** * 固定电话号码校验 * 固定电话号码校验 "XXX-XXXXXXX"、"XXXX-XXXXXXXX"、"XXX-XXXXXXX"、"XXX-XXXXXXXX"、"XXXXXXX"和"XXXXXXXX * @description 国际固定电话号码校验 * @param { string } tel 固定电话号码 * @return boolean * **/ declare function telPhoneReg(tel: string): boolean; /** * 域名正则校验(一级或二级域名) * @description url validate www.baidu.com test.baidu.com * @param { string } str 需要校验的字符串 * @return boolean */ declare function domainUrlReg(str: string): boolean; /** * 网络地址正则校验 * @description http or https 开头的链接 * @param { string } str 需要校验的字符串 * @param { 'https' | 'http' } agreement 可指定http或https * @return boolean */ declare function netWorkUrlReg(str: string, agreement?: 'https' | 'http'): boolean; /** * 身份证号码正则宽松校验 * @description 身份证号码(identity card number)中国, 只要是18位(支持末尾x|X)、15位数字即可 * @param { string } str 需要校验的字符串 * @return boolean * **/ declare function looseIdCardReg(str: string): boolean; /** * 身份证号码正则严格校验 * @description 身份证号码(identity card number)中国, 严格校验 * @param { string } str 需要校验的字符串 * @return boolean * **/ declare function strictIdCardReg(str: string): boolean; /** * 弱密码校验 @description 密码规则:密码长度为m ~ n个字符,只能包含数字、大写字母、小写字母和下划线组成(有其一即可) @param { string } str @param { [ number, number ] } len [ min, max ] 密码长度范围, 默认 6-15 @return boolean * **/ declare function loosePasswordReg(str: string, len?: [number, number]): boolean; /** * 简单密码校验 @description 密码规则:密码长度为m ~ n个字符,必须包含数字和字母(大小写均可),允许除空格外的特殊符号 @param { string } str @param { [ number, number ] } len [ min, max ] 密码长度范围, 默认 6-15 @return boolean * **/ declare function simplePasswordReg(str: string, len?: [number, number]): boolean; /** * 强密码正则校验 * @description 密码规则:密码长度为8 ~ 20个字符,由数字、大写字母、小写字母和特殊字符组成, 默认8-20位字符 * @param { string } str * @param { [ number, number ] } len [ min, max ] 密码长度范围 * @return boolean * **/ declare function strictPasswordReg(str: string, len?: [number, number]): boolean; /** * 昵称正则校验 * @description 昵称规则: 中文组合、英文数字组合,英文中文数字组合 * @param { string } str 需要校验的字符串 * @return boolean * **/ declare function fieldNameReg(str: string): boolean; /** * * @desc 十六进制颜色正则校验 * @param { string } str 需要校验的字符串 * @return boolean */ declare function hexColorReg(str: string): boolean; /** * @description 金额正则校验 *@param { string } str 需要校验的字符串 * @param { Object } options 配置项 * @param { number } options.decimalsMax 支持的小数位数,默认八位小数 * @param { boolean } options.minus 是否支持负数,默认false * @return boolean * **/ declare function moneyReg(str: string, options?: { minus?: boolean; decimalsMax?: number; }): boolean; /** * 千分位正则 * @description 千分位正则校验 10,000.00 100,000,000 199999 * @param { string } str 需要校验的字符串 *@return boolean * **/ declare function thousandsMoneyReg(str: string): boolean; /** * @description IP正则校验 * @param { string } str 需要校验的字符串 * @return boolean * **/ declare function ipReg(str: string): boolean; /** * 日期格式正则校验 * @description 校验日期格式 2020-01-01、2020/1/1 * param { string } str 需要校验的字符串 * @return boolean * **/ declare function dateReg(str: string): boolean; /** * 日期时间格式正则校验 * @description 校验日期格式 2020-01-01、2020-1-1 * param { string } str 需要校验的字符串 * @return boolean * **/ declare function dateTimeReg(str: string): boolean; /** * 大数输入值验证,整数大于0,小数点最高可达8位19.8n精度(特定场景使用) *@param { string } str 需要检查的字符串 * @return { boolean } 是否符合精度要求 * **/ declare function largeNumberReg(str: string): boolean; /** * 整数数字正则校验 * @description * @param { string } str 需要检查的字符串 * @param { boolean } minus 是否支持负数 * @return { boolean } 是否匹配 * **/ declare function integerReg(str: string, minus?: boolean): boolean; /** * 弱小数正则校验, 支持负数 * @description 只要是 xxx.xxx、-xxx.xxx 格式均可通过 * @param { string } str 需要检查的字符串 * @param { number } decimalsMax 最大小数位. 默认为8 * @return { boolean } 是否匹配 * **/ declare function looseDecimalsReg(str: string, decimalsMax?: number): boolean; /** * 严格小数正则校验, 支持负数 * @description 01.xxx 00.xxx 不可通过 * @param { string } str 需要检查的字符串 * @param { Object } options 配置项 * @param { number } options.decimalsMax 支持的小数位数,默认八位小数 * @param { boolean } options.minus 是否支持负数,默认false * **/ declare function strictDecimalsReg(str: string, options?: { decimalsMax?: number; minus?: boolean; }): boolean; export { allStrReg, chinaTelPhoneReg, chineseReg, customStrReg, dateReg, dateTimeReg, domainUrlReg, fieldNameReg, generalEmailReg, hexColorReg, integerReg, ipReg, largeNumberReg, letterNumberReg, letterReg, letterZhNumberReg, looseDecimalsReg, looseIdCardReg, loosePasswordReg, loosePhoneReg, lowerLetterReg, moneyReg, netWorkUrlReg, simplePasswordReg, specialStrReg, strictDecimalsReg, strictIdCardReg, strictPasswordReg, strictPhoneReg, telPhoneReg, thousandsMoneyReg, upperLetterReg };