Methods
(static) isBankCard(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为银行卡号
Example
isBankCard('6228480402564890018');
// => true
isBankCard('6228480402564890');
// => true
isBankCard('123456789');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为银行卡号
- Type
- Boolean
(static) isBusinessLicense(value, optionsopt) → {Boolean}
- Source:
- Since:
- 3.5.0
- See:
检测值是否为营业执照号,也叫工商注册号。由14位数字本体码和1位数字校验码组成,其中本体码从左至右依次为:6位首次登记机关码、8位顺序码。
Example
isBusinessLicense('310115600985533');
// => true
isBusinessLicense('3101156009');
// => false
isBusinessLicense('3101156009', { loose: true });
// => false
isBusinessLicense('310115600985535');
// => false
isBusinessLicense('310115600985535', { loose: true });
// => true
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String | 要检测的值 | |||||||||||
options |
Object |
<optional> |
配置项
Properties
|
Returns:
值是否为营业执照号
- Type
- Boolean
(static) isChinese(value, optionsopt) → {Boolean}
- Source:
- Since:
- 1.1.0
- See:
检测值是否为中文
Example
isChinese('林某某');
// => true
isChinese('林A');
// => false
// 宽松模式,只要包含中文即为true
isChinese('林A', {loose: true});
// => true
isChinese('A林A', {loose: true});
// => true
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String | 要检测的值 | |||||||||||
options |
Object |
<optional> |
配置项
Properties
|
Returns:
值是否为中文
- Type
- Boolean
(static) isEmail(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为Email
Example
isEmail('1232@qq.com');
// => true
isEmail('123@');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为Email
- Type
- Boolean
(static) isIdCard(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为身份证号
Example
isIdCard('320311770706001');
// => true
isIdCard('130701199310302288');
// => true
isIdCard('130701199310');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为身份证号
- Type
- Boolean
(static) isIPv4(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为ipv4
Example
isIPv4('192.168.1.1');
// => true
isIPv4('255.255.255.255');
// => true
isIPv4('256.256.256.256');
// => false
isIPv4('0.0');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为ipv4
- Type
- Boolean
(static) isIPv6(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为ipv6
Example
// 冒分十六进制表示法
isIPv6('2001:0DB8:0000:0023:0008:0800:200C:417A');
// => true
// 前导0省略
isIPv6('2001:DB8:0:23:8:800:200C:417A');
// => true
isIPv6('FF01:0:0:0:0:0:0:1101');
// => true
// 0位压缩表示法
isIPv6('FF01::1101');
// => true
isIPv6('::1');
// => true
isIPv6('::');
// => true
isIPv6('0:0:0:0:0:0:0:1');
// => true
isIPv6('0:0:0:0:0:0:0:0');
// => true
// 内嵌IPv4地址表示法
isIPv6('::192.168.1.1');
// => true
isIPv6('::FFFF:192.168.1.1');
// => true
isIPv6('192.168.1.1');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为ipv6
- Type
- Boolean
(static) isMobile(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为手机号码
Example
isMobile('13000000000');
// => true
isMobile('13000');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为手机号码
- Type
- Boolean
(static) isPassport(value) → {Boolean}
- Source:
- Since:
- 1.1.0
- See:
检测值是否为护照号
支持普通护照(E*)、外交护照(DE)、公务护照(SE)、公务普通护照(PE)、香港特区护照(K/KJ)、澳门特区护照(MA)
Example
isPassport('E12345678');
// => true
isPassport('abc');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为护照号
- Type
- Boolean
(static) isPassword(value, optionsopt) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否符合密码强度
注意该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度
Example
isPassword('a12345678');
// => true
isPassword('a12345678', {level: 3});
// => false
isPassword('Aa12345678', {level: 3});
// => true
isPassword('Aa12345678', {level: 3, ignoreCase: true});
// => false
isPassword('_Aa12345678', {level: 3, ignoreCase: true});
// => true
// 仅支持 数字、字母、特殊字符,其他字符如中文字符是校验不通过的
isPassword('_Aa一二三45678', {level: 3, ignoreCase: true});
// => false
isPassword(' _Aa12345678', {level: 3, ignoreCase: true});
// => false
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String | 要检测的值 | |||||||||||||||||||||
options |
Object |
<optional> |
配置项
Properties
|
Returns:
值是否符合密码强度
- Type
- Boolean
(static) isPostcode(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为邮政编码
Example
isPostcode('101111');
// => true
isPostcode('123');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为邮政编码
- Type
- Boolean
(static) isQQ(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为QQ号
Example
isQQ('12345');
// => true
isQQ('123');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为QQ号
- Type
- Boolean
(static) isSocialCreditCode(value, optionsopt) → {Boolean}
- Source:
- Since:
- 1.1.0
- See:
检测值是否为统一社会信用代码,也叫三证合一组织代码。由18位数字和大写字母组成,不使用I、O、Z、S、V。
Example
isSocialCreditCode('91350100M000100Y4A3');
// => true
isSocialCreditCode('91350100M000100Y4AB');
// => false
// 宽松模式,不校验校验位。所以也可以通过
isSocialCreditCode('91350100M000100Y4AB', {loose: true});
// => true
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String | 要检测的值 | |||||||||||
options |
Object |
<optional> |
配置项
Properties
|
Returns:
值是否为统一社会信用代码
- Type
- Boolean
(static) isTelephone(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为固定电话
Example
isTelephone('22033212');
// => true
isTelephone('021-22033212');
// => true
isTelephone('021-22033212-123');
// => true
isTelephone('13000000000');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为固定电话
- Type
- Boolean
(static) isUrl(value) → {Boolean}
- Source:
- Since:
- 3.4.0
检测值是否为url
Example
isUrl('');
// => false
isUrl('8.8.8.8');
// => false
isUrl('http://example.com');
// => true
isUrl('https://example.com:8080');
// => true
isUrl('http://www.example.com/test/123');
// => true
isUrl('http://www.example.com/test/123?foo=bar');
// => true
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为url
- Type
- Boolean
(static) isVehicle(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为车牌号
Example
isVehicle('京L88888');
// => true
isVehicle('333333');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为车牌号
- Type
- Boolean
(static) isWX(value) → {Boolean}
- Source:
- Since:
- 1.1.0
检测值是否为微信号
Example
isWX('a12345');
// => true
isWX('123');
// => false
Parameters:
Name | Type | Description |
---|---|---|
value |
String | 要检测的值 |
Returns:
值是否为微信号
- Type
- Boolean