validator
Advanced tools
Comparing version 13.5.2 to 13.6.0
656
CHANGELOG.md
@@ -1,4 +0,48 @@ | ||
#### 13.5.0 | ||
#### 13.6.1 | ||
- **New features**: | ||
- [#1495](https://github.com/validatorjs/validator.js/pull/1495) `isLicensePlate` @firlus | ||
- **Fixes and Enhancements**: | ||
- [#1651](https://github.com/validatorjs/validator.js/pull/1651) fix ReDOS vulnerabilities in `isHSL` and `isEmail` @tux-tn | ||
- [#1644](https://github.com/validatorjs/validator.js/pull/1644) `isURL`: Allow URLs to have only a username in the userinfo subcomponent @jbuchmann-coosto | ||
- [#1633](https://github.com/validatorjs/validator.js/pull/1633) `isISIN`: optimization @bmacnaughton | ||
- [#1632](https://github.com/validatorjs/validator.js/pull/1632) `isIP`: improved pattern for IPv4 and IPv6 @ognjenjevremovic | ||
- [#1625](https://github.com/validatorjs/validator.js/pull/1625) fix `[A-z]` regex range on some validators @bmacnaughton | ||
- [#1620](https://github.com/validatorjs/validator.js/pull/1620) fix docs @prahaladbelavadi | ||
- [#1616](https://github.com/validatorjs/validator.js/pull/1616) `isMacAddress`: improve regexes and options @fedeci | ||
- [#1603](https://github.com/validatorjs/validator.js/pull/1603) fix ReDOS vulnerabilities in `isSlug` and `rtrim` @fedeci | ||
- [#1594](https://github.com/validatorjs/validator.js/pull/1594) `isIPRange`: add support for IPv6 @neilime | ||
- [#1577](https://github.com/validatorjs/validator.js/pull/1577) `isEAN`: add support for EAN-14 @varsubham @tux-tn | ||
- [#1566](https://github.com/validatorjs/validator.js/pull/1566) `isStrongPassword`: add `@` as a valid symbol @stingalleman | ||
- [#1548](https://github.com/validatorjs/validator.js/pull/1548) `isBtcAddress`: add base58 @ezkemboi | ||
- [#1546](https://github.com/validatorjs/validator.js/pull/1546) `isFQDN`: numeric domain names @tux-tn | ||
- **New and Improved locales**: | ||
- `isIdentityCard`, `isPassportNumber`: | ||
- [#1595](https://github.com/validatorjs/validator.js/pull/1595) `IR` @mhf-ir @fedeci | ||
- [#1583](https://github.com/validatorjs/validator.js/pull/1583) `ar-LY` @asghaier76 @tux-tn | ||
- [#1574](https://github.com/validatorjs/validator.js/pull/1574) `MY` @stranger26 @tux-tn | ||
- `isMobilePhone`: | ||
- [#1642](https://github.com/validatorjs/validator.js/pull/1642) `zh-CN` @Akira0705 | ||
- [#1638](https://github.com/validatorjs/validator.js/pull/1638) `lv-LV` @AntonLukichev | ||
- [#1635](https://github.com/validatorjs/validator.js/pull/1635) `en-GH` @ankorGH | ||
- [#1604](https://github.com/validatorjs/validator.js/pull/1604) `mz-MZ` @salmento @tux-tn | ||
- [#1575](https://github.com/validatorjs/validator.js/pull/1575) `vi-VN` @kyled7 | ||
- [#1573](https://github.com/validatorjs/validator.js/pull/1573) `en-SG` @liliwei25 | ||
- [#1554](https://github.com/validatorjs/validator.js/pull/1554) `de-CH`, `fr-CH`, `it-CH` @dinfekted | ||
- [#1541](https://github.com/validatorjs/validator.js/pull/1541) [#1623](https://github.com/validatorjs/validator.js/pull/1623) `es-CO` @ezkemboi @tux-tn | ||
- [#1506](https://github.com/validatorjs/validator.js/pull/1506) `ar-OM` @dev-sna | ||
- [#1505](https://github.com/validatorjs/validator.js/pull/1505) `pt-AO` @AdilsonFuxe | ||
- `isPostalCode`: | ||
- [#1628](https://github.com/validatorjs/validator.js/pull/1628) `KR` @greatSumini | ||
- `isTaxID`: | ||
- [#1613](https://github.com/validatorjs/validator.js/pull/1613) `pt-BR` @mschunke | ||
- [#1529](https://github.com/validatorjs/validator.js/pull/1529) `el-GR` @dspinellis | ||
- `isVAT`: | ||
- [#1536](https://github.com/validatorjs/validator.js/pull/1536) `IT` @fedeci | ||
#### ~~13.5.0~~ 13.5.1 | ||
- **New features**: | ||
- `isVAT` [#1463](https://github.com/validatorjs/validator.js/pull/1463) @ CodingNagger | ||
@@ -87,3 +131,3 @@ - `isTaxID` [#1446](https://github.com/validatorjs/validator.js/pull/1446) @tplessas | ||
- Hotfix for a regex incompatibility in some browsers | ||
([#1355](https://github.com/chriso/validator.js/pull/1355) | ||
([#1355](https://github.com/validatorjs/validator.js/pull/1355) | ||
@@ -93,43 +137,43 @@ #### 13.1.0 | ||
- Added an `isIMEI()` validator | ||
([#1346](https://github.com/chriso/validator.js/pull/1346)) | ||
([#1346](https://github.com/validatorjs/validator.js/pull/1346)) | ||
- Added an `isDate()` validator | ||
([#1270](https://github.com/chriso/validator.js/pull/1270)) | ||
([#1270](https://github.com/validatorjs/validator.js/pull/1270)) | ||
- Added an `isTaxID()` validator | ||
([#1336](https://github.com/chriso/validator.js/pull/1336)) | ||
([#1336](https://github.com/validatorjs/validator.js/pull/1336)) | ||
- Added DMS support to `isLatLong()` | ||
([#1340](https://github.com/chriso/validator.js/pull/1340)) | ||
([#1340](https://github.com/validatorjs/validator.js/pull/1340)) | ||
- Added support for URL-safe base64 validation | ||
([#1277](https://github.com/chriso/validator.js/pull/1277)) | ||
([#1277](https://github.com/validatorjs/validator.js/pull/1277)) | ||
- Added support for primitives in `isJSON()` | ||
([#1328](https://github.com/chriso/validator.js/pull/1328)) | ||
([#1328](https://github.com/validatorjs/validator.js/pull/1328)) | ||
- Added support for case-insensitive matching to `contains()` | ||
([#1334](https://github.com/chriso/validator.js/pull/1334)) | ||
([#1334](https://github.com/validatorjs/validator.js/pull/1334)) | ||
- Support additional cards in `isCreditCard()` | ||
([#1177](https://github.com/chriso/validator.js/pull/1177)) | ||
([#1177](https://github.com/validatorjs/validator.js/pull/1177)) | ||
- Support additional currencies in `isCurrency()` | ||
([#1306](https://github.com/chriso/validator.js/pull/1306)) | ||
([#1306](https://github.com/validatorjs/validator.js/pull/1306)) | ||
- Fixed `isFQDN()` handling of certain special chars | ||
([#1091](https://github.com/chriso/validator.js/pull/1091)) | ||
([#1091](https://github.com/validatorjs/validator.js/pull/1091)) | ||
- Fixed a bug in `isSlug()` | ||
([#1338](https://github.com/chriso/validator.js/pull/1338)) | ||
([#1338](https://github.com/validatorjs/validator.js/pull/1338)) | ||
- New and improved locales | ||
([#1112](https://github.com/chriso/validator.js/pull/1112), | ||
[#1167](https://github.com/chriso/validator.js/pull/1167), | ||
[#1198](https://github.com/chriso/validator.js/pull/1198), | ||
[#1199](https://github.com/chriso/validator.js/pull/1199), | ||
[#1273](https://github.com/chriso/validator.js/pull/1273), | ||
[#1279](https://github.com/chriso/validator.js/pull/1279), | ||
[#1281](https://github.com/chriso/validator.js/pull/1281), | ||
[#1293](https://github.com/chriso/validator.js/pull/1293), | ||
[#1294](https://github.com/chriso/validator.js/pull/1294), | ||
[#1311](https://github.com/chriso/validator.js/pull/1311), | ||
[#1312](https://github.com/chriso/validator.js/pull/1312), | ||
[#1313](https://github.com/chriso/validator.js/pull/1313), | ||
[#1314](https://github.com/chriso/validator.js/pull/1314), | ||
[#1315](https://github.com/chriso/validator.js/pull/1315), | ||
[#1317](https://github.com/chriso/validator.js/pull/1317), | ||
[#1322](https://github.com/chriso/validator.js/pull/1322), | ||
[#1324](https://github.com/chriso/validator.js/pull/1324), | ||
[#1330](https://github.com/chriso/validator.js/pull/1330), | ||
[#1337](https://github.com/chriso/validator.js/pull/1337)) | ||
([#1112](https://github.com/validatorjs/validator.js/pull/1112), | ||
[#1167](https://github.com/validatorjs/validator.js/pull/1167), | ||
[#1198](https://github.com/validatorjs/validator.js/pull/1198), | ||
[#1199](https://github.com/validatorjs/validator.js/pull/1199), | ||
[#1273](https://github.com/validatorjs/validator.js/pull/1273), | ||
[#1279](https://github.com/validatorjs/validator.js/pull/1279), | ||
[#1281](https://github.com/validatorjs/validator.js/pull/1281), | ||
[#1293](https://github.com/validatorjs/validator.js/pull/1293), | ||
[#1294](https://github.com/validatorjs/validator.js/pull/1294), | ||
[#1311](https://github.com/validatorjs/validator.js/pull/1311), | ||
[#1312](https://github.com/validatorjs/validator.js/pull/1312), | ||
[#1313](https://github.com/validatorjs/validator.js/pull/1313), | ||
[#1314](https://github.com/validatorjs/validator.js/pull/1314), | ||
[#1315](https://github.com/validatorjs/validator.js/pull/1315), | ||
[#1317](https://github.com/validatorjs/validator.js/pull/1317), | ||
[#1322](https://github.com/validatorjs/validator.js/pull/1322), | ||
[#1324](https://github.com/validatorjs/validator.js/pull/1324), | ||
[#1330](https://github.com/validatorjs/validator.js/pull/1330), | ||
[#1337](https://github.com/validatorjs/validator.js/pull/1337)) | ||
@@ -140,30 +184,30 @@ #### 13.0.0 | ||
to validate [Ethereum addresses](https://en.wikipedia.org/wiki/Ethereum#Addresses) | ||
([#1117](https://github.com/chriso/validator.js/pull/1117)) | ||
([#1117](https://github.com/validatorjs/validator.js/pull/1117)) | ||
- Added `isBtcAddress()` validator | ||
to validate [Bitcoin addresses](https://en.bitcoin.it/wiki/Address) | ||
([#1163](https://github.com/chriso/validator.js/pull/1163)) | ||
([#1163](https://github.com/validatorjs/validator.js/pull/1163)) | ||
- Added `isIBAN()` validator | ||
to validate [International Bank Account Numbers](https://en.wikipedia.org/wiki/International_Bank_Account_Number) | ||
([#1243](https://github.com/chriso/validator.js/pull/1243)) | ||
([#1243](https://github.com/validatorjs/validator.js/pull/1243)) | ||
- Added `isEAN()` validator | ||
to validate [International Article Numbers](https://en.wikipedia.org/wiki/International_Article_Number) | ||
([#1244](https://github.com/chriso/validator.js/pull/1244)) | ||
([#1244](https://github.com/validatorjs/validator.js/pull/1244)) | ||
- Added `isSemVer()` validator | ||
to validate [Semantic Version Numbers](https://semver.org) | ||
([#1246](https://github.com/chriso/validator.js/pull/1246)) | ||
([#1246](https://github.com/validatorjs/validator.js/pull/1246)) | ||
- Added `isPassportNumber()` validator | ||
([#1250](https://github.com/chriso/validator.js/pull/1250)) | ||
([#1250](https://github.com/validatorjs/validator.js/pull/1250)) | ||
- Added `isRgbColor()` validator | ||
([#1141](https://github.com/chriso/validator.js/pull/1141)) | ||
([#1141](https://github.com/validatorjs/validator.js/pull/1141)) | ||
- Added `isHSL()` validator | ||
([#1159](https://github.com/chriso/validator.js/pull/1159)) | ||
([#1159](https://github.com/validatorjs/validator.js/pull/1159)) | ||
- Added `isLocale()` validator | ||
([#1072](https://github.com/chriso/validator.js/pull/1072)) | ||
([#1072](https://github.com/validatorjs/validator.js/pull/1072)) | ||
- Improved the `isIP()` validator | ||
([#1211](https://github.com/chriso/validator.js/pull/1211)) | ||
([#1211](https://github.com/validatorjs/validator.js/pull/1211)) | ||
- Improved the `isMACAddress()` validator | ||
([#1267](https://github.com/chriso/validator.js/pull/1267)) | ||
([#1267](https://github.com/validatorjs/validator.js/pull/1267)) | ||
- New and improved locales | ||
([#1238](https://github.com/chriso/validator.js/pull/1238), | ||
[#1265](https://github.com/chriso/validator.js/pull/1265)) | ||
([#1238](https://github.com/validatorjs/validator.js/pull/1238), | ||
[#1265](https://github.com/validatorjs/validator.js/pull/1265)) | ||
@@ -173,11 +217,11 @@ #### 12.2.0 | ||
- Support CSS Colors Level 4 spec | ||
([#1233](https://github.com/chriso/validator.js/pull/1233)) | ||
([#1233](https://github.com/validatorjs/validator.js/pull/1233)) | ||
- Improve the `toFloat()` sanitizer | ||
([#1227](https://github.com/chriso/validator.js/pull/1227)) | ||
([#1227](https://github.com/validatorjs/validator.js/pull/1227)) | ||
- New and improved locales | ||
([#1200](https://github.com/chriso/validator.js/pull/1200), | ||
[#1207](https://github.com/chriso/validator.js/pull/1207), | ||
[#1213](https://github.com/chriso/validator.js/pull/1213), | ||
[#1217](https://github.com/chriso/validator.js/pull/1217), | ||
[#1234](https://github.com/chriso/validator.js/pull/1234)) | ||
([#1200](https://github.com/validatorjs/validator.js/pull/1200), | ||
[#1207](https://github.com/validatorjs/validator.js/pull/1207), | ||
[#1213](https://github.com/validatorjs/validator.js/pull/1213), | ||
[#1217](https://github.com/validatorjs/validator.js/pull/1217), | ||
[#1234](https://github.com/validatorjs/validator.js/pull/1234)) | ||
@@ -187,10 +231,10 @@ #### 12.1.0 | ||
- ES module for webpack tree shaking | ||
([#1015](https://github.com/chriso/validator.js/pull/1015)) | ||
([#1015](https://github.com/validatorjs/validator.js/pull/1015)) | ||
- Updated `isIP()` to accept scoped IPv6 addresses | ||
([#1160](https://github.com/chriso/validator.js/pull/1160)) | ||
([#1160](https://github.com/validatorjs/validator.js/pull/1160)) | ||
- New and improved locales | ||
([#1162](https://github.com/chriso/validator.js/pull/1162), | ||
[#1183](https://github.com/chriso/validator.js/pull/1183), | ||
[#1187](https://github.com/chriso/validator.js/pull/1187), | ||
[#1191](https://github.com/chriso/validator.js/pull/1191)) | ||
([#1162](https://github.com/validatorjs/validator.js/pull/1162), | ||
[#1183](https://github.com/validatorjs/validator.js/pull/1183), | ||
[#1187](https://github.com/validatorjs/validator.js/pull/1187), | ||
[#1191](https://github.com/validatorjs/validator.js/pull/1191)) | ||
@@ -200,31 +244,31 @@ #### 12.0.0 | ||
- Added `isOctal()` validator | ||
([#1153](https://github.com/chriso/validator.js/pull/1153)) | ||
([#1153](https://github.com/validatorjs/validator.js/pull/1153)) | ||
- Added `isSlug()` validator | ||
([#1096](https://github.com/chriso/validator.js/pull/1096)) | ||
([#1096](https://github.com/validatorjs/validator.js/pull/1096)) | ||
- Added `isBIC()` validator for bank identification codes | ||
([#1071](https://github.com/chriso/validator.js/pull/1071)) | ||
([#1071](https://github.com/validatorjs/validator.js/pull/1071)) | ||
- Allow uppercase chars in `isHash()` | ||
([#1062](https://github.com/chriso/validator.js/pull/1062)) | ||
([#1062](https://github.com/validatorjs/validator.js/pull/1062)) | ||
- Allow additional prefixes in `isHexadecimal()` | ||
([#1147](https://github.com/chriso/validator.js/pull/1147)) | ||
([#1147](https://github.com/validatorjs/validator.js/pull/1147)) | ||
- Allow additional separators in `isMACAddress()` | ||
([#1065](https://github.com/chriso/validator.js/pull/1065)) | ||
([#1065](https://github.com/validatorjs/validator.js/pull/1065)) | ||
- Better defaults for `isLength()` | ||
([#1070](https://github.com/chriso/validator.js/pull/1070)) | ||
([#1070](https://github.com/validatorjs/validator.js/pull/1070)) | ||
- Bug fixes | ||
([#1074](https://github.com/chriso/validator.js/pull/1074)) | ||
([#1074](https://github.com/validatorjs/validator.js/pull/1074)) | ||
- New and improved locales | ||
([#1059](https://github.com/chriso/validator.js/pull/1059), | ||
[#1060](https://github.com/chriso/validator.js/pull/1060), | ||
[#1069](https://github.com/chriso/validator.js/pull/1069), | ||
[#1073](https://github.com/chriso/validator.js/pull/1073), | ||
[#1082](https://github.com/chriso/validator.js/pull/1082), | ||
[#1092](https://github.com/chriso/validator.js/pull/1092), | ||
[#1121](https://github.com/chriso/validator.js/pull/1121), | ||
[#1125](https://github.com/chriso/validator.js/pull/1125), | ||
[#1132](https://github.com/chriso/validator.js/pull/1132), | ||
[#1152](https://github.com/chriso/validator.js/pull/1152), | ||
[#1165](https://github.com/chriso/validator.js/pull/1165), | ||
[#1166](https://github.com/chriso/validator.js/pull/1166), | ||
[#1174](https://github.com/chriso/validator.js/pull/1174)) | ||
([#1059](https://github.com/validatorjs/validator.js/pull/1059), | ||
[#1060](https://github.com/validatorjs/validator.js/pull/1060), | ||
[#1069](https://github.com/validatorjs/validator.js/pull/1069), | ||
[#1073](https://github.com/validatorjs/validator.js/pull/1073), | ||
[#1082](https://github.com/validatorjs/validator.js/pull/1082), | ||
[#1092](https://github.com/validatorjs/validator.js/pull/1092), | ||
[#1121](https://github.com/validatorjs/validator.js/pull/1121), | ||
[#1125](https://github.com/validatorjs/validator.js/pull/1125), | ||
[#1132](https://github.com/validatorjs/validator.js/pull/1132), | ||
[#1152](https://github.com/validatorjs/validator.js/pull/1152), | ||
[#1165](https://github.com/validatorjs/validator.js/pull/1165), | ||
[#1166](https://github.com/validatorjs/validator.js/pull/1166), | ||
[#1174](https://github.com/validatorjs/validator.js/pull/1174)) | ||
@@ -234,14 +278,14 @@ #### 11.1.0 | ||
- Code coverage improvements | ||
([#1024](https://github.com/chriso/validator.js/pull/1024)) | ||
([#1024](https://github.com/validatorjs/validator.js/pull/1024)) | ||
- New and improved locales | ||
([#1035](https://github.com/chriso/validator.js/pull/1035), | ||
[#1040](https://github.com/chriso/validator.js/pull/1040), | ||
[#1041](https://github.com/chriso/validator.js/pull/1041), | ||
[#1048](https://github.com/chriso/validator.js/pull/1048), | ||
[#1049](https://github.com/chriso/validator.js/pull/1049), | ||
[#1052](https://github.com/chriso/validator.js/pull/1052), | ||
[#1054](https://github.com/chriso/validator.js/pull/1054), | ||
[#1055](https://github.com/chriso/validator.js/pull/1055), | ||
[#1056](https://github.com/chriso/validator.js/pull/1056), | ||
[#1057](https://github.com/chriso/validator.js/pull/1057)) | ||
([#1035](https://github.com/validatorjs/validator.js/pull/1035), | ||
[#1040](https://github.com/validatorjs/validator.js/pull/1040), | ||
[#1041](https://github.com/validatorjs/validator.js/pull/1041), | ||
[#1048](https://github.com/validatorjs/validator.js/pull/1048), | ||
[#1049](https://github.com/validatorjs/validator.js/pull/1049), | ||
[#1052](https://github.com/validatorjs/validator.js/pull/1052), | ||
[#1054](https://github.com/validatorjs/validator.js/pull/1054), | ||
[#1055](https://github.com/validatorjs/validator.js/pull/1055), | ||
[#1056](https://github.com/validatorjs/validator.js/pull/1056), | ||
[#1057](https://github.com/validatorjs/validator.js/pull/1057)) | ||
@@ -251,16 +295,16 @@ #### 11.0.0 | ||
- Added a `isBase32()` validator | ||
([#1023](https://github.com/chriso/validator.js/pull/1023)) | ||
([#1023](https://github.com/validatorjs/validator.js/pull/1023)) | ||
- Updated `isEmail()` to validate display names according to RFC2822 | ||
([#1004](https://github.com/chriso/validator.js/pull/1004)) | ||
([#1004](https://github.com/validatorjs/validator.js/pull/1004)) | ||
- Updated `isEmail()` to check total email length | ||
([#1007](https://github.com/chriso/validator.js/pull/1007)) | ||
([#1007](https://github.com/validatorjs/validator.js/pull/1007)) | ||
- The internal `toString()` util is no longer exported | ||
([0277eb](https://github.com/chriso/validator.js/commit/0277eb00d245a3479af52adf7d927d4036895650)) | ||
([0277eb](https://github.com/validatorjs/validator.js/commit/0277eb00d245a3479af52adf7d927d4036895650)) | ||
- New and improved locales | ||
([#999](https://github.com/chriso/validator.js/pull/999), | ||
[#1010](https://github.com/chriso/validator.js/pull/1010), | ||
[#1017](https://github.com/chriso/validator.js/pull/1017), | ||
[#1022](https://github.com/chriso/validator.js/pull/1022), | ||
[#1031](https://github.com/chriso/validator.js/pull/1031), | ||
[#1032](https://github.com/chriso/validator.js/pull/1032)) | ||
([#999](https://github.com/validatorjs/validator.js/pull/999), | ||
[#1010](https://github.com/validatorjs/validator.js/pull/1010), | ||
[#1017](https://github.com/validatorjs/validator.js/pull/1017), | ||
[#1022](https://github.com/validatorjs/validator.js/pull/1022), | ||
[#1031](https://github.com/validatorjs/validator.js/pull/1031), | ||
[#1032](https://github.com/validatorjs/validator.js/pull/1032)) | ||
@@ -270,5 +314,5 @@ #### 10.11.0 | ||
- Fix imports like `import .. from "validator/lib/.."` | ||
([#961](https://github.com/chriso/validator.js/pull/961)) | ||
([#961](https://github.com/validatorjs/validator.js/pull/961)) | ||
- New locale | ||
([#958](https://github.com/chriso/validator.js/pull/958)) | ||
([#958](https://github.com/validatorjs/validator.js/pull/958)) | ||
@@ -278,8 +322,8 @@ #### 10.10.0 | ||
- `isISO8601()` strict mode now works in the browser | ||
([#932](https://github.com/chriso/validator.js/pull/932)) | ||
([#932](https://github.com/validatorjs/validator.js/pull/932)) | ||
- New and improved locales | ||
([#931](https://github.com/chriso/validator.js/pull/931), | ||
[#933](https://github.com/chriso/validator.js/pull/933), | ||
[#947](https://github.com/chriso/validator.js/pull/947), | ||
[#950](https://github.com/chriso/validator.js/pull/950)) | ||
([#931](https://github.com/validatorjs/validator.js/pull/931), | ||
[#933](https://github.com/validatorjs/validator.js/pull/933), | ||
[#947](https://github.com/validatorjs/validator.js/pull/947), | ||
[#950](https://github.com/validatorjs/validator.js/pull/950)) | ||
@@ -289,14 +333,14 @@ #### 10.9.0 | ||
- Added an option to `isURL()` to reject email-like URLs | ||
([#901](https://github.com/chriso/validator.js/pull/901)) | ||
([#901](https://github.com/validatorjs/validator.js/pull/901)) | ||
- Added a `strict` option to `isISO8601()` | ||
([#910](https://github.com/chriso/validator.js/pull/910)) | ||
([#910](https://github.com/validatorjs/validator.js/pull/910)) | ||
- Relaxed `isJWT()` signature requirements | ||
([#906](https://github.com/chriso/validator.js/pull/906)) | ||
([#906](https://github.com/validatorjs/validator.js/pull/906)) | ||
- New and improved locales | ||
([#899](https://github.com/chriso/validator.js/pull/899), | ||
[#904](https://github.com/chriso/validator.js/pull/904), | ||
[#913](https://github.com/chriso/validator.js/pull/913), | ||
[#916](https://github.com/chriso/validator.js/pull/916), | ||
[#925](https://github.com/chriso/validator.js/pull/925), | ||
[#928](https://github.com/chriso/validator.js/pull/928)) | ||
([#899](https://github.com/validatorjs/validator.js/pull/899), | ||
[#904](https://github.com/validatorjs/validator.js/pull/904), | ||
[#913](https://github.com/validatorjs/validator.js/pull/913), | ||
[#916](https://github.com/validatorjs/validator.js/pull/916), | ||
[#925](https://github.com/validatorjs/validator.js/pull/925), | ||
[#928](https://github.com/validatorjs/validator.js/pull/928)) | ||
@@ -306,10 +350,10 @@ #### 10.8.0 | ||
- Added `isIdentityCard()` | ||
([#846](https://github.com/chriso/validator.js/pull/846)) | ||
([#846](https://github.com/validatorjs/validator.js/pull/846)) | ||
- Better error when validators are passed an invalid type | ||
([#895](https://github.com/chriso/validator.js/pull/895)) | ||
([#895](https://github.com/validatorjs/validator.js/pull/895)) | ||
- Locales are now exported | ||
([#890](https://github.com/chriso/validator.js/pull/890), | ||
[#892](https://github.com/chriso/validator.js/pull/892)) | ||
([#890](https://github.com/validatorjs/validator.js/pull/890), | ||
[#892](https://github.com/validatorjs/validator.js/pull/892)) | ||
- New locale | ||
([#896](https://github.com/chriso/validator.js/pull/896)) | ||
([#896](https://github.com/validatorjs/validator.js/pull/896)) | ||
@@ -319,5 +363,5 @@ #### 10.7.1 | ||
- Ignore case when checking URL protocol | ||
([#887](https://github.com/chriso/validator.js/issues/887)) | ||
([#887](https://github.com/validatorjs/validator.js/issues/887)) | ||
- Locale fix | ||
([#889](https://github.com/chriso/validator.js/pull/889)) | ||
([#889](https://github.com/validatorjs/validator.js/pull/889)) | ||
@@ -327,5 +371,5 @@ #### 10.7.0 | ||
- Added `isMagnetURI()` to validate [magnet URIs](https://en.wikipedia.org/wiki/Magnet_URI_scheme) | ||
([#884](https://github.com/chriso/validator.js/pull/884)) | ||
([#884](https://github.com/validatorjs/validator.js/pull/884)) | ||
- Added `isJWT()` to validate [JSON web tokens](https://en.wikipedia.org/wiki/JSON_Web_Token) | ||
([#885](https://github.com/chriso/validator.js/pull/885)) | ||
([#885](https://github.com/validatorjs/validator.js/pull/885)) | ||
@@ -335,8 +379,8 @@ #### 10.6.0 | ||
- Updated `isMobilePhone()` to match any locale's pattern by default | ||
([#874](https://github.com/chriso/validator.js/pull/874)) | ||
([#874](https://github.com/validatorjs/validator.js/pull/874)) | ||
- Added an option to ignore whitespace in `isEmpty()` | ||
([#880](https://github.com/chriso/validator.js/pull/880)) | ||
([#880](https://github.com/validatorjs/validator.js/pull/880)) | ||
- New and improved locales | ||
([#878](https://github.com/chriso/validator.js/pull/878), | ||
[#879](https://github.com/chriso/validator.js/pull/879)) | ||
([#878](https://github.com/validatorjs/validator.js/pull/878), | ||
[#879](https://github.com/validatorjs/validator.js/pull/879)) | ||
@@ -346,21 +390,21 @@ #### 10.5.0 | ||
- Disabled domain-specific email validation | ||
([#873](https://github.com/chriso/validator.js/pull/873)) | ||
([#873](https://github.com/validatorjs/validator.js/pull/873)) | ||
- Added support for IP hostnames in `isEmail()` | ||
([#845](https://github.com/chriso/validator.js/pull/845)) | ||
([#845](https://github.com/validatorjs/validator.js/pull/845)) | ||
- Added a `no_symbols` option to `isNumeric()` | ||
([#848](https://github.com/chriso/validator.js/pull/848)) | ||
([#848](https://github.com/validatorjs/validator.js/pull/848)) | ||
- Added a `no_colons` option to `isMACAddress()` | ||
([#849](https://github.com/chriso/validator.js/pull/849)) | ||
([#849](https://github.com/validatorjs/validator.js/pull/849)) | ||
- Updated `isURL()` to reject protocol relative URLs unless a flag is set | ||
([#860](https://github.com/chriso/validator.js/issues/860)) | ||
([#860](https://github.com/validatorjs/validator.js/issues/860)) | ||
- New and improved locales | ||
([#801](https://github.com/chriso/validator.js/pull/801), | ||
[#856](https://github.com/chriso/validator.js/pull/856), | ||
[#859](https://github.com/chriso/validator.js/issues/859), | ||
[#861](https://github.com/chriso/validator.js/pull/861), | ||
[#862](https://github.com/chriso/validator.js/pull/862), | ||
[#863](https://github.com/chriso/validator.js/pull/863), | ||
[#864](https://github.com/chriso/validator.js/pull/864), | ||
[#870](https://github.com/chriso/validator.js/pull/870), | ||
[#872](https://github.com/chriso/validator.js/pull/872)) | ||
([#801](https://github.com/validatorjs/validator.js/pull/801), | ||
[#856](https://github.com/validatorjs/validator.js/pull/856), | ||
[#859](https://github.com/validatorjs/validator.js/issues/859), | ||
[#861](https://github.com/validatorjs/validator.js/pull/861), | ||
[#862](https://github.com/validatorjs/validator.js/pull/862), | ||
[#863](https://github.com/validatorjs/validator.js/pull/863), | ||
[#864](https://github.com/validatorjs/validator.js/pull/864), | ||
[#870](https://github.com/validatorjs/validator.js/pull/870), | ||
[#872](https://github.com/validatorjs/validator.js/pull/872)) | ||
@@ -370,7 +414,7 @@ #### 10.4.0 | ||
- Added an `isIPRange()` validator | ||
([#842](https://github.com/chriso/validator.js/pull/842)) | ||
([#842](https://github.com/validatorjs/validator.js/pull/842)) | ||
- Accept an array of locales in `isMobilePhone()` | ||
([#742](https://github.com/chriso/validator.js/pull/742)) | ||
([#742](https://github.com/validatorjs/validator.js/pull/742)) | ||
- New locale | ||
([#843](https://github.com/chriso/validator.js/pull/843)) | ||
([#843](https://github.com/validatorjs/validator.js/pull/843)) | ||
@@ -380,7 +424,7 @@ #### 10.3.0 | ||
- Strict Gmail validation in `isEmail()` | ||
([#832](https://github.com/chriso/validator.js/pull/832)) | ||
([#832](https://github.com/validatorjs/validator.js/pull/832)) | ||
- New locales | ||
([#831](https://github.com/chriso/validator.js/pull/831), | ||
[#835](https://github.com/chriso/validator.js/pull/835), | ||
[#836](https://github.com/chriso/validator.js/pull/836)) | ||
([#831](https://github.com/validatorjs/validator.js/pull/831), | ||
[#835](https://github.com/validatorjs/validator.js/pull/835), | ||
[#836](https://github.com/validatorjs/validator.js/pull/836)) | ||
@@ -390,3 +434,3 @@ #### 10.2.0 | ||
- Export the list of supported locales in `isPostalCode()` | ||
([#830](https://github.com/chriso/validator.js/pull/830)) | ||
([#830](https://github.com/validatorjs/validator.js/pull/830)) | ||
@@ -396,3 +440,3 @@ #### 10.1.0 | ||
- Added an `isISO31661Alpha3()` validator | ||
([#809](https://github.com/chriso/validator.js/pull/809)) | ||
([#809](https://github.com/validatorjs/validator.js/pull/809)) | ||
@@ -402,17 +446,17 @@ #### 10.0.0 | ||
- Allow floating points in `isNumeric()` | ||
([#810](https://github.com/chriso/validator.js/pull/810)) | ||
([#810](https://github.com/validatorjs/validator.js/pull/810)) | ||
- Disallow GMail addresses with multiple consecutive dots, or leading/trailing dots | ||
([#820](https://github.com/chriso/validator.js/pull/820)) | ||
([#820](https://github.com/validatorjs/validator.js/pull/820)) | ||
- Added an `isRFC3339()` validator | ||
([#816](https://github.com/chriso/validator.js/pull/816)) | ||
([#816](https://github.com/validatorjs/validator.js/pull/816)) | ||
- Reject domain parts longer than 63 octets in `isFQDN()`, `isURL()` and `isEmail()` | ||
([bb3e542](https://github.com/chriso/validator.js/commit/bb3e542)) | ||
([bb3e542](https://github.com/validatorjs/validator.js/commit/bb3e542)) | ||
- Added a new Amex prefix to `isCreditCard()` | ||
([#805](https://github.com/chriso/validator.js/pull/805)) | ||
([#805](https://github.com/validatorjs/validator.js/pull/805)) | ||
- Fixed `isFloat()` min/max/gt/lt filters when a locale with a comma decimal is used | ||
([2b70821](https://github.com/chriso/validator.js/commit/2b70821)) | ||
([2b70821](https://github.com/validatorjs/validator.js/commit/2b70821)) | ||
- Normalize Yandex emails | ||
([#807](https://github.com/chriso/validator.js/pull/807)) | ||
([#807](https://github.com/validatorjs/validator.js/pull/807)) | ||
- New locales | ||
([#803](https://github.com/chriso/validator.js/pull/803)) | ||
([#803](https://github.com/validatorjs/validator.js/pull/803)) | ||
@@ -423,3 +467,3 @@ #### 9.4.1 | ||
- New and improved locales | ||
([#788](https://github.com/chriso/validator.js/pull/788)) | ||
([#788](https://github.com/validatorjs/validator.js/pull/788)) | ||
@@ -429,5 +473,5 @@ #### 9.4.0 | ||
- Added an option to `isMobilePhone` to require a country code | ||
([#769](https://github.com/chriso/validator.js/pull/769)) | ||
([#769](https://github.com/validatorjs/validator.js/pull/769)) | ||
- New and improved locales | ||
([#785](https://github.com/chriso/validator.js/pull/785)) | ||
([#785](https://github.com/validatorjs/validator.js/pull/785)) | ||
@@ -437,7 +481,7 @@ #### 9.3.0 | ||
- New and improved locales | ||
([#763](https://github.com/chriso/validator.js/pull/763), | ||
[#768](https://github.com/chriso/validator.js/pull/768), | ||
[#774](https://github.com/chriso/validator.js/pull/774), | ||
[#777](https://github.com/chriso/validator.js/pull/777), | ||
[#779](https://github.com/chriso/validator.js/pull/779)) | ||
([#763](https://github.com/validatorjs/validator.js/pull/763), | ||
[#768](https://github.com/validatorjs/validator.js/pull/768), | ||
[#774](https://github.com/validatorjs/validator.js/pull/774), | ||
[#777](https://github.com/validatorjs/validator.js/pull/777), | ||
[#779](https://github.com/validatorjs/validator.js/pull/779)) | ||
@@ -447,7 +491,7 @@ #### 9.2.0 | ||
- Added an `isMimeType()` validator | ||
([#760](https://github.com/chriso/validator.js/pull/760)) | ||
([#760](https://github.com/validatorjs/validator.js/pull/760)) | ||
- New and improved locales | ||
([#753](https://github.com/chriso/validator.js/pull/753), | ||
[#755](https://github.com/chriso/validator.js/pull/755), | ||
[#764](https://github.com/chriso/validator.js/pull/764)) | ||
([#753](https://github.com/validatorjs/validator.js/pull/753), | ||
[#755](https://github.com/validatorjs/validator.js/pull/755), | ||
[#764](https://github.com/validatorjs/validator.js/pull/764)) | ||
@@ -457,3 +501,3 @@ #### 9.1.2 | ||
- Fixed a bug with the `isFloat` validator | ||
([#752](https://github.com/chriso/validator.js/pull/752)) | ||
([#752](https://github.com/validatorjs/validator.js/pull/752)) | ||
@@ -463,4 +507,4 @@ #### 9.1.1 | ||
- Locale fixes | ||
([#738](https://github.com/chriso/validator.js/pull/738), | ||
[#739](https://github.com/chriso/validator.js/pull/739)) | ||
([#738](https://github.com/validatorjs/validator.js/pull/738), | ||
[#739](https://github.com/validatorjs/validator.js/pull/739)) | ||
@@ -470,6 +514,6 @@ #### 9.1.0 | ||
- Added an `isISO31661Alpha2()` validator | ||
([#734](https://github.com/chriso/validator.js/pull/734)) | ||
([#734](https://github.com/validatorjs/validator.js/pull/734)) | ||
- New locales | ||
([#735](https://github.com/chriso/validator.js/pull/735), | ||
[#737](https://github.com/chriso/validator.js/pull/737)) | ||
([#735](https://github.com/validatorjs/validator.js/pull/735), | ||
[#737](https://github.com/validatorjs/validator.js/pull/737)) | ||
@@ -479,9 +523,9 @@ #### 9.0.0 | ||
- `normalizeEmail()` no longer validates the email address | ||
([#725](https://github.com/chriso/validator.js/pull/725)) | ||
([#725](https://github.com/validatorjs/validator.js/pull/725)) | ||
- Added locale-aware validation to `isFloat()` and `isDecimal()` | ||
([#721](https://github.com/chriso/validator.js/pull/721)) | ||
([#721](https://github.com/validatorjs/validator.js/pull/721)) | ||
- Added an `isPort()` validator | ||
([#733](https://github.com/chriso/validator.js/pull/733)) | ||
([#733](https://github.com/validatorjs/validator.js/pull/733)) | ||
- New locales | ||
([#731](https://github.com/chriso/validator.js/pull/731)) | ||
([#731](https://github.com/validatorjs/validator.js/pull/731)) | ||
@@ -491,11 +535,11 @@ #### 8.2.0 | ||
- Added an `isHash()` validator | ||
([#711](https://github.com/chriso/validator.js/pull/711)) | ||
([#711](https://github.com/validatorjs/validator.js/pull/711)) | ||
- Control decimal places in `isCurrency()` | ||
([#713](https://github.com/chriso/validator.js/pull/713)) | ||
([#713](https://github.com/validatorjs/validator.js/pull/713)) | ||
- New and improved locales | ||
([#700](https://github.com/chriso/validator.js/pull/700), | ||
[#701](https://github.com/chriso/validator.js/pull/701), | ||
[#714](https://github.com/chriso/validator.js/pull/714), | ||
[#715](https://github.com/chriso/validator.js/pull/715), | ||
[#718](https://github.com/chriso/validator.js/pull/718)) | ||
([#700](https://github.com/validatorjs/validator.js/pull/700), | ||
[#701](https://github.com/validatorjs/validator.js/pull/701), | ||
[#714](https://github.com/validatorjs/validator.js/pull/714), | ||
[#715](https://github.com/validatorjs/validator.js/pull/715), | ||
[#718](https://github.com/validatorjs/validator.js/pull/718)) | ||
@@ -505,13 +549,13 @@ #### 8.1.0 | ||
- Fix `require('validator/lib/isIS8601')` calls | ||
([#688](https://github.com/chriso/validator.js/issues/688)) | ||
([#688](https://github.com/validatorjs/validator.js/issues/688)) | ||
- Added an `isLatLong()` and `isPostalCode()` validator | ||
([#684](https://github.com/chriso/validator.js/pull/684)) | ||
([#684](https://github.com/validatorjs/validator.js/pull/684)) | ||
- Allow comma in email display names | ||
([#692](https://github.com/chriso/validator.js/pull/692)) | ||
([#692](https://github.com/validatorjs/validator.js/pull/692)) | ||
- Add missing string to `unescape()` | ||
([#690](https://github.com/chriso/validator.js/pull/690)) | ||
([#690](https://github.com/validatorjs/validator.js/pull/690)) | ||
- Fix `isMobilePhone()` with Node <= 6.x | ||
([#681](https://github.com/chriso/validator.js/issues/681)) | ||
([#681](https://github.com/validatorjs/validator.js/issues/681)) | ||
- New locales | ||
([#695](https://github.com/chriso/validator.js/pull/695)) | ||
([#695](https://github.com/validatorjs/validator.js/pull/695)) | ||
@@ -521,7 +565,7 @@ #### 8.0.0 | ||
- `isURL()` now requires the `require_tld: false` option to validate `localhost` | ||
([#675](https://github.com/chriso/validator.js/issues/675)) | ||
([#675](https://github.com/validatorjs/validator.js/issues/675)) | ||
- `isURL()` now rejects URLs that are protocol only | ||
([#642](https://github.com/chriso/validator.js/issues/642)) | ||
([#642](https://github.com/validatorjs/validator.js/issues/642)) | ||
- Fixed a bug where `isMobilePhone()` would silently return false if the locale was invalid or unsupported | ||
([#657](https://github.com/chriso/validator.js/issues/657)) | ||
([#657](https://github.com/validatorjs/validator.js/issues/657)) | ||
@@ -531,10 +575,10 @@ #### 7.2.0 | ||
- Added an option to validate any phone locale | ||
([#663](https://github.com/chriso/validator.js/pull/663)) | ||
([#663](https://github.com/validatorjs/validator.js/pull/663)) | ||
- Fixed a bug in credit card validation | ||
([#672](https://github.com/chriso/validator.js/pull/672)) | ||
([#672](https://github.com/validatorjs/validator.js/pull/672)) | ||
- Disallow whitespace, including unicode whitespace, in TLDs | ||
([#677](https://github.com/chriso/validator.js/pull/677)) | ||
([#677](https://github.com/validatorjs/validator.js/pull/677)) | ||
- New locales | ||
([#673](https://github.com/chriso/validator.js/pull/673), | ||
[#676](https://github.com/chriso/validator.js/pull/676)) | ||
([#673](https://github.com/validatorjs/validator.js/pull/673), | ||
[#676](https://github.com/validatorjs/validator.js/pull/676)) | ||
@@ -544,13 +588,13 @@ #### 7.1.0 | ||
- Added an `isISRC()` validator for [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code) | ||
([#660](https://github.com/chriso/validator.js/pull/660)) | ||
([#660](https://github.com/validatorjs/validator.js/pull/660)) | ||
- Fixed a bug in credit card validation | ||
([#670](https://github.com/chriso/validator.js/pull/670)) | ||
([#670](https://github.com/validatorjs/validator.js/pull/670)) | ||
- Reduced the maximum allowed address in `isEmail()` based on | ||
[RFC3696 errata](http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690) | ||
([#655](https://github.com/chriso/validator.js/issues/655)) | ||
([#655](https://github.com/validatorjs/validator.js/issues/655)) | ||
- New locales | ||
([#647](https://github.com/chriso/validator.js/pull/647), | ||
[#667](https://github.com/chriso/validator.js/pull/667), | ||
[#667](https://github.com/chriso/validator.js/pull/667), | ||
[#671](https://github.com/chriso/validator.js/pull/671)) | ||
([#647](https://github.com/validatorjs/validator.js/pull/647), | ||
[#667](https://github.com/validatorjs/validator.js/pull/667), | ||
[#667](https://github.com/validatorjs/validator.js/pull/667), | ||
[#671](https://github.com/validatorjs/validator.js/pull/671)) | ||
@@ -564,8 +608,8 @@ #### 7.0.0 | ||
- Allow values like `-.01` in `isFloat()` | ||
([#618](https://github.com/chriso/validator.js/issues/618)) | ||
([#618](https://github.com/validatorjs/validator.js/issues/618)) | ||
- New locales | ||
([#616](https://github.com/chriso/validator.js/pull/616), | ||
[#622](https://github.com/chriso/validator.js/pull/622), | ||
[#627](https://github.com/chriso/validator.js/pull/627), | ||
[#630](https://github.com/chriso/validator.js/pull/630)) | ||
([#616](https://github.com/validatorjs/validator.js/pull/616), | ||
[#622](https://github.com/validatorjs/validator.js/pull/622), | ||
[#627](https://github.com/validatorjs/validator.js/pull/627), | ||
[#630](https://github.com/validatorjs/validator.js/pull/630)) | ||
@@ -575,5 +619,5 @@ #### 6.2.1 | ||
- Disallow `<` and `>` in URLs | ||
([#613](https://github.com/chriso/validator.js/issues/613)) | ||
([#613](https://github.com/validatorjs/validator.js/issues/613)) | ||
- New locales | ||
([#610](https://github.com/chriso/validator.js/pull/610)) | ||
([#610](https://github.com/validatorjs/validator.js/pull/610)) | ||
@@ -583,7 +627,7 @@ #### 6.2.0 | ||
- Added an option to require an email display name | ||
([#607](https://github.com/chriso/validator.js/pull/607)) | ||
([#607](https://github.com/validatorjs/validator.js/pull/607)) | ||
- Added support for `lt` and `gt` to `isInt()` | ||
([#588](https://github.com/chriso/validator.js/pull/588)) | ||
([#588](https://github.com/validatorjs/validator.js/pull/588)) | ||
- New locales | ||
([#601](https://github.com/chriso/validator.js/pull/601)) | ||
([#601](https://github.com/validatorjs/validator.js/pull/601)) | ||
@@ -593,9 +637,9 @@ #### 6.1.0 | ||
- Added support for greater or less than in `isFloat()` | ||
([#544](https://github.com/chriso/validator.js/issues/544)) | ||
([#544](https://github.com/validatorjs/validator.js/issues/544)) | ||
- Added support for ISSN validation via `isISSN()` | ||
([#593](https://github.com/chriso/validator.js/pull/593)) | ||
([#593](https://github.com/validatorjs/validator.js/pull/593)) | ||
- Fixed a bug in `normalizeEmail()` | ||
([#594](https://github.com/chriso/validator.js/issues/594)) | ||
([#594](https://github.com/validatorjs/validator.js/issues/594)) | ||
- New locales | ||
([#585](https://github.com/chriso/validator.js/pull/585)) | ||
([#585](https://github.com/validatorjs/validator.js/pull/585)) | ||
@@ -605,9 +649,9 @@ #### 6.0.0 | ||
- Renamed `isNull()` to `isEmpty()` | ||
([#574](https://github.com/chriso/validator.js/issues/574)) | ||
([#574](https://github.com/validatorjs/validator.js/issues/574)) | ||
- Backslash is now escaped in `escape()` | ||
([#516](https://github.com/chriso/validator.js/issues/516)) | ||
([#516](https://github.com/validatorjs/validator.js/issues/516)) | ||
- Improved `normalizeEmail()` | ||
([#583](https://github.com/chriso/validator.js/pull/583)) | ||
([#583](https://github.com/validatorjs/validator.js/pull/583)) | ||
- Allow leading zeroes by default in `isInt()` | ||
([#532](https://github.com/chriso/validator.js/pull/532)) | ||
([#532](https://github.com/validatorjs/validator.js/pull/532)) | ||
@@ -617,12 +661,12 @@ #### 5.7.0 | ||
- Added support for IPv6 in `isURL()` | ||
([#564](https://github.com/chriso/validator.js/issues/564)) | ||
([#564](https://github.com/validatorjs/validator.js/issues/564)) | ||
- Added support for urls without a host (e.g. `file:///foo.txt`) in `isURL()` | ||
([#563](https://github.com/chriso/validator.js/issues/563)) | ||
([#563](https://github.com/validatorjs/validator.js/issues/563)) | ||
- Added support for regular expressions in the `isURL()` host whitelist and blacklist | ||
([#562](https://github.com/chriso/validator.js/issues/562)) | ||
([#562](https://github.com/validatorjs/validator.js/issues/562)) | ||
- Added support for MasterCard 2-Series BIN | ||
([#576](https://github.com/chriso/validator.js/pull/576)) | ||
([#576](https://github.com/validatorjs/validator.js/pull/576)) | ||
- New locales | ||
([#575](https://github.com/chriso/validator.js/pull/575), | ||
[#552](https://github.com/chriso/validator.js/issues/552)) | ||
([#575](https://github.com/validatorjs/validator.js/pull/575), | ||
[#552](https://github.com/validatorjs/validator.js/issues/552)) | ||
@@ -632,10 +676,10 @@ #### 5.6.0 | ||
- Added an `isMD5()` validator | ||
([#557](https://github.com/chriso/validator.js/pull/557)) | ||
([#557](https://github.com/validatorjs/validator.js/pull/557)) | ||
- Fixed an exceptional case in `isDate()` | ||
([#566](https://github.com/chriso/validator.js/pull/566)) | ||
([#566](https://github.com/validatorjs/validator.js/pull/566)) | ||
- New locales | ||
([#559](https://github.com/chriso/validator.js/pull/559), | ||
[#568](https://github.com/chriso/validator.js/pull/568), | ||
[#571](https://github.com/chriso/validator.js/pull/571), | ||
[#573](https://github.com/chriso/validator.js/pull/573)) | ||
([#559](https://github.com/validatorjs/validator.js/pull/559), | ||
[#568](https://github.com/validatorjs/validator.js/pull/568), | ||
[#571](https://github.com/validatorjs/validator.js/pull/571), | ||
[#573](https://github.com/validatorjs/validator.js/pull/573)) | ||
@@ -645,9 +689,9 @@ #### 5.5.0 | ||
- Fixed a regex denial of service in `trim()` and `rtrim()` | ||
([#556](https://github.com/chriso/validator.js/pull/556)) | ||
([#556](https://github.com/validatorjs/validator.js/pull/556)) | ||
- Added an Algerian locale to `isMobilePhone()` | ||
([#540](https://github.com/chriso/validator.js/pull/540)) | ||
([#540](https://github.com/validatorjs/validator.js/pull/540)) | ||
- Fixed the Hungarian locale in `isAlpha()` and `isAlphanumeric()` | ||
([#541](https://github.com/chriso/validator.js/pull/541)) | ||
([#541](https://github.com/validatorjs/validator.js/pull/541)) | ||
- Added a Polish locale to `isMobilePhone()` | ||
([#545](https://github.com/chriso/validator.js/pull/545)) | ||
([#545](https://github.com/validatorjs/validator.js/pull/545)) | ||
@@ -657,7 +701,7 @@ #### 5.4.0 | ||
- Accept Union Pay credit cards in `isCreditCard()` | ||
([#539](https://github.com/chriso/validator.js/pull/539)) | ||
([#539](https://github.com/validatorjs/validator.js/pull/539)) | ||
- Added Danish locale to `isMobilePhone()` | ||
([#538](https://github.com/chriso/validator.js/pull/538)) | ||
([#538](https://github.com/validatorjs/validator.js/pull/538)) | ||
- Added Hungarian locales to `isAlpha()`, `isAlphanumeric()` and `isMobilePhone()` | ||
([#537](https://github.com/chriso/validator.js/pull/537)) | ||
([#537](https://github.com/validatorjs/validator.js/pull/537)) | ||
@@ -667,7 +711,7 @@ #### 5.3.0 | ||
- Added an `allow_leading_zeroes` option to `isInt()` | ||
([#532](https://github.com/chriso/validator.js/pull/532)) | ||
([#532](https://github.com/validatorjs/validator.js/pull/532)) | ||
- Adjust Chinese mobile phone validation | ||
([#523](https://github.com/chriso/validator.js/pull/523)) | ||
([#523](https://github.com/validatorjs/validator.js/pull/523)) | ||
- Added a Canadian locale to `isMobilePhone()` | ||
([#524](https://github.com/chriso/validator.js/issues/524)) | ||
([#524](https://github.com/validatorjs/validator.js/issues/524)) | ||
@@ -677,7 +721,7 @@ #### 5.2.0 | ||
- Added a `isDataURI()` validator | ||
([#521](https://github.com/chriso/validator.js/pull/521)) | ||
([#521](https://github.com/validatorjs/validator.js/pull/521)) | ||
- Added Czech locales | ||
([#522](https://github.com/chriso/validator.js/pull/522)) | ||
([#522](https://github.com/validatorjs/validator.js/pull/522)) | ||
- Fixed a bug with `isURL()` when protocol was missing and "://" appeared in the query | ||
([#518](https://github.com/chriso/validator.js/issues/518)) | ||
([#518](https://github.com/validatorjs/validator.js/issues/518)) | ||
@@ -687,11 +731,11 @@ #### 5.1.0 | ||
- Added a `unescape()` HTML function | ||
([#509](https://github.com/chriso/validator.js/pull/509)) | ||
([#509](https://github.com/validatorjs/validator.js/pull/509)) | ||
- Added a Malaysian locale to `isMobilePhone()` | ||
([#507](https://github.com/chriso/validator.js/pull/507)) | ||
([#507](https://github.com/validatorjs/validator.js/pull/507)) | ||
- Added Polish locales to `isAlpha()` and `isAlphanumeric()` | ||
([#506](https://github.com/chriso/validator.js/pull/506)) | ||
([#506](https://github.com/validatorjs/validator.js/pull/506)) | ||
- Added Turkish locales to `isAlpha()`, `isAlphanumeric()` and `isMobilePhone()` | ||
([#512](https://github.com/chriso/validator.js/pull/512)) | ||
([#512](https://github.com/validatorjs/validator.js/pull/512)) | ||
- Allow >1 underscore in hostnames when using `allow_underscores` | ||
([#510](https://github.com/chriso/validator.js/issues/510)) | ||
([#510](https://github.com/validatorjs/validator.js/issues/510)) | ||
@@ -701,13 +745,13 @@ #### 5.0.0 | ||
- Migrate to ES6 | ||
([#496](https://github.com/chriso/validator.js/pull/496)) | ||
([#496](https://github.com/validatorjs/validator.js/pull/496)) | ||
- Break the library up so that individual functions can be imported | ||
([#496](https://github.com/chriso/validator.js/pull/496)) | ||
([#496](https://github.com/validatorjs/validator.js/pull/496)) | ||
- Remove auto-coercion of input to a string | ||
([#496](https://github.com/chriso/validator.js/pull/496)) | ||
([#496](https://github.com/validatorjs/validator.js/pull/496)) | ||
- Remove the `extend()` function | ||
([#496](https://github.com/chriso/validator.js/pull/496)) | ||
([#496](https://github.com/validatorjs/validator.js/pull/496)) | ||
- Added Arabic locales to `isAlpha()` and `isAlphanumeric()` | ||
([#496](https://github.com/chriso/validator.js/pull/496#issuecomment-184781730)) | ||
([#496](https://github.com/validatorjs/validator.js/pull/496#issuecomment-184781730)) | ||
- Fix validation of very large base64 strings | ||
([#503](https://github.com/chriso/validator.js/pull/503)) | ||
([#503](https://github.com/validatorjs/validator.js/pull/503)) | ||
@@ -717,5 +761,5 @@ #### 4.9.0 | ||
- Added a Russian locale to `isAlpha()` and `isAlphanumeric()` | ||
([#499](https://github.com/chriso/validator.js/pull/499)) | ||
([#499](https://github.com/validatorjs/validator.js/pull/499)) | ||
- Remove the restriction on adjacent hyphens in hostnames | ||
([#500](https://github.com/chriso/validator.js/issues/500)) | ||
([#500](https://github.com/validatorjs/validator.js/issues/500)) | ||
@@ -725,9 +769,9 @@ #### 4.8.0 | ||
- Added Spanish, French, Portuguese and Dutch support for `isAlpha()` and `isAlphanumeric()` | ||
([#492](https://github.com/chriso/validator.js/pull/492)) | ||
([#492](https://github.com/validatorjs/validator.js/pull/492)) | ||
- Added a Brazilian locale to `isMobilePhone()` | ||
([#489](https://github.com/chriso/validator.js/pull/489)) | ||
([#489](https://github.com/validatorjs/validator.js/pull/489)) | ||
- Reject IPv4 addresses with invalid zero padding | ||
([#490](https://github.com/chriso/validator.js/pull/490)) | ||
([#490](https://github.com/validatorjs/validator.js/pull/490)) | ||
- Fix the client-side version when used with RequireJS | ||
([#494](https://github.com/chriso/validator.js/issues/494)) | ||
([#494](https://github.com/validatorjs/validator.js/issues/494)) | ||
@@ -737,3 +781,3 @@ #### 4.7.1 | ||
- Use [node-depd](https://github.com/dougwilson/nodejs-depd) to print deprecation notices | ||
([#487](https://github.com/chriso/validator.js/issues/487)) | ||
([#487](https://github.com/validatorjs/validator.js/issues/487)) | ||
@@ -743,8 +787,8 @@ #### 4.7.0 | ||
- Print a deprecation warning if validator input is not a string | ||
([1f67e1e](https://github.com/chriso/validator.js/commit/1f67e1e15198c0ae735151290dc8dc2bf14da254)). | ||
([1f67e1e](https://github.com/validatorjs/validator.js/commit/1f67e1e15198c0ae735151290dc8dc2bf14da254)). | ||
Note that this will be an error in v5. | ||
- Added a German locale to `isMobilePhone()`, `isAlpha()` and `isAlphanumeric()` | ||
([#477](https://github.com/chriso/validator.js/pull/477)) | ||
([#477](https://github.com/validatorjs/validator.js/pull/477)) | ||
- Added a Finnish locale to `isMobilePhone()` | ||
([#455](https://github.com/chriso/validator.js/pull/455)) | ||
([#455](https://github.com/validatorjs/validator.js/pull/455)) | ||
@@ -754,3 +798,3 @@ #### 4.6.1 | ||
- Fix coercion of objects: `Object.toString()` is `[object Object]` not `""` | ||
([a57f3c8](https://github.com/chriso/validator.js/commit/a57f3c843c715fba2664ee22ec80e9e28e88e0a6)) | ||
([a57f3c8](https://github.com/validatorjs/validator.js/commit/a57f3c843c715fba2664ee22ec80e9e28e88e0a6)) | ||
@@ -760,5 +804,5 @@ #### 4.6.0 | ||
- Added a Spanish locale to `isMobilePhone()` | ||
([#481](https://github.com/chriso/validator.js/pull/481)) | ||
([#481](https://github.com/validatorjs/validator.js/pull/481)) | ||
- Fix string coercion of objects created with `Object.create(null)` | ||
([#484](https://github.com/chriso/validator.js/issues/484)) | ||
([#484](https://github.com/validatorjs/validator.js/issues/484)) | ||
@@ -769,3 +813,3 @@ #### 4.5.2 | ||
`validator.isDate('2011-12-21')` | ||
([#480](https://github.com/chriso/validator.js/issues/480)) | ||
([#480](https://github.com/validatorjs/validator.js/issues/480)) | ||
@@ -775,3 +819,3 @@ #### 4.5.1 | ||
- Make `isLength()` / `isByteLength()` accept `{min, max}` as options object. | ||
([#474](https://github.com/chriso/validator.js/issues/474)) | ||
([#474](https://github.com/validatorjs/validator.js/issues/474)) | ||
@@ -781,8 +825,8 @@ #### 4.5.0 | ||
- Add validation for Indian mobile phone numbers | ||
([#471](https://github.com/chriso/validator.js/pull/471)) | ||
([#471](https://github.com/validatorjs/validator.js/pull/471)) | ||
- Tweak Greek and Chinese mobile phone validation | ||
([#467](https://github.com/chriso/validator.js/pull/467), | ||
[#468](https://github.com/chriso/validator.js/pull/468)) | ||
([#467](https://github.com/validatorjs/validator.js/pull/467), | ||
[#468](https://github.com/validatorjs/validator.js/pull/468)) | ||
- Fixed a bug in `isDate()` when validating ISO 8601 dates without a timezone | ||
([#472](https://github.com/chriso/validator.js/issues/472)) | ||
([#472](https://github.com/validatorjs/validator.js/issues/472)) | ||
@@ -792,3 +836,3 @@ #### 4.4.1 | ||
- Allow triple hyphens in IDNA hostnames | ||
([#466](https://github.com/chriso/validator.js/issues/466)) | ||
([#466](https://github.com/validatorjs/validator.js/issues/466)) | ||
@@ -798,9 +842,9 @@ #### 4.4.0 | ||
- Added `isMACAddress()` validator | ||
([#458](https://github.com/chriso/validator.js/pull/458)) | ||
([#458](https://github.com/validatorjs/validator.js/pull/458)) | ||
- Added `isWhitelisted()` validator | ||
([#462](https://github.com/chriso/validator.js/pull/462)) | ||
([#462](https://github.com/validatorjs/validator.js/pull/462)) | ||
- Added a New Zealand locale to `isMobilePhone()` | ||
([#452](https://github.com/chriso/validator.js/pull/452)) | ||
([#452](https://github.com/validatorjs/validator.js/pull/452)) | ||
- Added options to control GMail address normalization | ||
([#460](https://github.com/chriso/validator.js/pull/460)) | ||
([#460](https://github.com/validatorjs/validator.js/pull/460)) | ||
@@ -810,5 +854,5 @@ #### 4.3.0 | ||
- Support Ember CLI module definitions | ||
([#448](https://github.com/chriso/validator.js/pull/448)) | ||
([#448](https://github.com/validatorjs/validator.js/pull/448)) | ||
- Added a Vietnam locale to `isMobilePhone()` | ||
([#451](https://github.com/chriso/validator.js/pull/451)) | ||
([#451](https://github.com/validatorjs/validator.js/pull/451)) | ||
@@ -818,3 +862,3 @@ #### 4.2.1 | ||
- Fix `isDate()` handling of RFC2822 timezones | ||
([#447](https://github.com/chriso/validator.js/pull/447)) | ||
([#447](https://github.com/validatorjs/validator.js/pull/447)) | ||
@@ -824,7 +868,7 @@ #### 4.2.0 | ||
- Fix `isDate()` handling of ISO8601 timezones | ||
([#444](https://github.com/chriso/validator.js/pull/444)) | ||
([#444](https://github.com/validatorjs/validator.js/pull/444)) | ||
- Fix the incorrect `isFloat('.') === true` | ||
([#443](https://github.com/chriso/validator.js/pull/443)) | ||
([#443](https://github.com/validatorjs/validator.js/pull/443)) | ||
- Added a Norwegian locale to `isMobilePhone()` | ||
([#439](https://github.com/chriso/validator.js/pull/439)) | ||
([#439](https://github.com/validatorjs/validator.js/pull/439)) | ||
@@ -834,5 +878,5 @@ #### 4.1.0 | ||
- General `isDate()` improvements | ||
([#431](https://github.com/chriso/validator.js/pull/431)) | ||
([#431](https://github.com/validatorjs/validator.js/pull/431)) | ||
- Tests now require node 4.0+ | ||
([#438](https://github.com/chriso/validator.js/pull/438)) | ||
([#438](https://github.com/validatorjs/validator.js/pull/438)) | ||
@@ -842,5 +886,5 @@ #### 4.0.6 | ||
- Added a Taiwan locale to `isMobilePhone()` | ||
([#432](https://github.com/chriso/validator.js/pull/432)) | ||
([#432](https://github.com/validatorjs/validator.js/pull/432)) | ||
- Fixed a bug in `isBefore()` where it would return `null` | ||
([#436](https://github.com/chriso/validator.js/pull/436)) | ||
([#436](https://github.com/validatorjs/validator.js/pull/436)) | ||
@@ -850,3 +894,3 @@ #### 4.0.5 | ||
- Fixed a denial of service vulnerability in the `isEmail()` regex | ||
([#152](https://github.com/chriso/validator.js/issues/152#issuecomment-131874928)) | ||
([#152](https://github.com/validatorjs/validator.js/issues/152#issuecomment-131874928)) | ||
@@ -856,3 +900,3 @@ #### 4.0.4 | ||
- Reverted the leap year validation in `isDate()` as it introduced some regressions | ||
([#422](https://github.com/chriso/validator.js/issues/422), [#423](https://github.com/chriso/validator.js/issues/423)) | ||
([#422](https://github.com/validatorjs/validator.js/issues/422), [#423](https://github.com/validatorjs/validator.js/issues/423)) | ||
@@ -862,3 +906,3 @@ #### 4.0.3 | ||
- Added leap year validation to `isDate()` | ||
([#418](https://github.com/chriso/validator.js/pull/418)) | ||
([#418](https://github.com/validatorjs/validator.js/pull/418)) | ||
@@ -868,3 +912,3 @@ #### 4.0.2 | ||
- Fixed `isDecimal()` with an empty string | ||
([#419](https://github.com/chriso/validator.js/issues/419)) | ||
([#419](https://github.com/validatorjs/validator.js/issues/419)) | ||
@@ -874,5 +918,5 @@ #### 4.0.1 | ||
- Fixed `isByteLength()` with certain strings | ||
([09f0c6d](https://github.com/chriso/validator.js/commit/09f0c6d2321f0c78af6a7de42e91b63955e4c01e)) | ||
([09f0c6d](https://github.com/validatorjs/validator.js/commit/09f0c6d2321f0c78af6a7de42e91b63955e4c01e)) | ||
- Put length restrictions on email parts | ||
([#258](https://github.com/chriso/validator.js/issues/258#issuecomment-127173612)) | ||
([#258](https://github.com/validatorjs/validator.js/issues/258#issuecomment-127173612)) | ||
@@ -882,4 +926,4 @@ #### 4.0.0 | ||
- Simplified the `isEmail()` regex and fixed some edge cases | ||
([#258](https://github.com/chriso/validator.js/issues/258#issuecomment-127173612)) | ||
([#258](https://github.com/validatorjs/validator.js/issues/258#issuecomment-127173612)) | ||
- Added ISO 8601 date validation via `isISO8601()` | ||
([#373](https://github.com/chriso/validator.js/issues/373)) | ||
([#373](https://github.com/validatorjs/validator.js/issues/373)) |
@@ -90,5 +90,6 @@ import toDate from './lib/toDate'; | ||
import isSlug from './lib/isSlug'; | ||
import isLicensePlate from './lib/isLicensePlate'; | ||
import isStrongPassword from './lib/isStrongPassword'; | ||
import isVAT from './lib/isVAT'; | ||
var version = '13.5.2'; | ||
var version = '13.6.0'; | ||
var validator = { | ||
@@ -192,4 +193,5 @@ version: version, | ||
isDate: isDate, | ||
isLicensePlate: isLicensePlate, | ||
isVAT: isVAT | ||
}; | ||
export default validator; |
import assertString from './util/assertString'; | ||
import { alphanumeric } from './alpha'; | ||
export default function isAlphanumeric(str) { | ||
export default function isAlphanumeric(_str) { | ||
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US'; | ||
assertString(str); | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
assertString(_str); | ||
var str = _str; | ||
var ignore = options.ignore; | ||
if (ignore) { | ||
if (ignore instanceof RegExp) { | ||
str = str.replace(ignore, ''); | ||
} else if (typeof ignore === 'string') { | ||
str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore | ||
} else { | ||
throw new Error('ignore should be instance of a String or RegExp'); | ||
} | ||
} | ||
if (locale in alphanumeric) { | ||
@@ -8,0 +21,0 @@ return alphanumeric[locale].test(str); |
import assertString from './util/assertString'; | ||
var isBICReg = /^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/; | ||
import { CountryCodes } from './isISO31661Alpha2'; // https://en.wikipedia.org/wiki/ISO_9362 | ||
var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/; | ||
export default function isBIC(str) { | ||
assertString(str); | ||
assertString(str); // toUpperCase() should be removed when a new major version goes out that changes | ||
// the regex to [A-Z] (per the spec). | ||
if (CountryCodes.indexOf(str.slice(4, 6).toUpperCase()) < 0) { | ||
return false; | ||
} | ||
return isBICReg.test(str); | ||
} |
import assertString from './util/assertString'; // supports Bech32 addresses | ||
var btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; | ||
var bech32 = /^(bc1)[a-z0-9]{25,39}$/; | ||
var base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/; | ||
export default function isBtcAddress(str) { | ||
assertString(str); | ||
return btc.test(str); | ||
assertString(str); // check for bech32 | ||
if (str.startsWith('bc1')) { | ||
return bech32.test(str); | ||
} | ||
return base58.test(str); | ||
} |
@@ -27,4 +27,3 @@ import assertString from './util/assertString'; | ||
for (var i = 0; i < attributes.length; i++) { | ||
if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {// ok | ||
} else if (!validAttribute.test(attributes[i])) { | ||
if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) { | ||
return false; | ||
@@ -31,0 +30,0 @@ } |
@@ -6,15 +6,20 @@ /** | ||
* introduced for use on small packages. | ||
* Also EAN/UCC-14 is used for Grouping of individual | ||
* trade items above unit level(Intermediate, Carton or Pallet). | ||
* For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/ | ||
* EAN consists of: | ||
* GS1 prefix, manufacturer code, product code and check digit | ||
* Reference: https://en.wikipedia.org/wiki/International_Article_Number | ||
* Reference: https://www.gtin.info/ | ||
*/ | ||
import assertString from './util/assertString'; | ||
/** | ||
* Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13 | ||
* and Regular Expression for valid EANs (EAN-8, EAN-13), | ||
* with exact numberic matching of 8 or 13 digits [0-9] | ||
* Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14 | ||
* and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14), | ||
* with exact numberic matching of 8 or 13 or 14 digits [0-9] | ||
*/ | ||
var LENGTH_EAN_8 = 8; | ||
var validEanRegex = /^(\d{8}|\d{13})$/; | ||
var LENGTH_EAN_14 = 14; | ||
var validEanRegex = /^(\d{8}|\d{13}|\d{14})$/; | ||
/** | ||
@@ -30,3 +35,3 @@ * Get position weight given: | ||
function getPositionWeightThroughLengthAndIndex(length, index) { | ||
if (length === LENGTH_EAN_8) { | ||
if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) { | ||
return index % 2 === 0 ? 3 : 1; | ||
@@ -57,3 +62,3 @@ } | ||
* Check if string is valid EAN: | ||
* Matches EAN-8/EAN-13 regex | ||
* Matches EAN-8/EAN-13/EAN-14 regex | ||
* Has valid check digit. | ||
@@ -60,0 +65,0 @@ * |
@@ -1,13 +0,1 @@ | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import assertString from './util/assertString'; | ||
@@ -30,3 +18,3 @@ import merge from './util/merge'; | ||
var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)<(.+)>$/i; | ||
var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i; | ||
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i; | ||
@@ -48,4 +36,3 @@ var gmailUserPart = /^[a-z\d]+$/; | ||
function validateDisplayName(display_name) { | ||
var trim_quotes = display_name.match(/^"(.+)"$/i); | ||
var display_name_without_quotes = trim_quotes ? trim_quotes[1] : display_name; // display name with only spaces is not valid | ||
var display_name_without_quotes = display_name.replace(/^"(.+)"$/, '$1'); // display name with only spaces is not valid | ||
@@ -62,3 +49,3 @@ if (!display_name_without_quotes.trim()) { | ||
// must to be enclosed in double-quotes, otherwise it's not a valid display name | ||
if (!trim_quotes) { | ||
if (display_name_without_quotes === display_name) { | ||
return false; | ||
@@ -86,13 +73,10 @@ } // the quotes in display name must start with character symbol \ | ||
if (display_email) { | ||
var display_name; | ||
var display_name = display_email[1]; // Remove display name and angle brackets to get email address | ||
// Can be done in the regex but will introduce a ReDOS (See #1597 for more info) | ||
var _display_email = _slicedToArray(display_email, 3); | ||
display_name = _display_email[1]; | ||
str = _display_email[2]; | ||
// sometimes need to trim the last space to get the display name | ||
str = str.replace(display_name, '').replace(/(^<|>$)/g, ''); // sometimes need to trim the last space to get the display name | ||
// because there may be a space between display name and email address | ||
// eg. myname <address@gmail.com> | ||
// the display name is `myname` instead of `myname `, so need to trim the last space | ||
if (display_name.endsWith(' ')) { | ||
@@ -183,4 +167,4 @@ display_name = display_name.substr(0, display_name.length - 1); | ||
for (var _i2 = 0; _i2 < user_parts.length; _i2++) { | ||
if (!pattern.test(user_parts[_i2])) { | ||
for (var _i = 0; _i < user_parts.length; _i++) { | ||
if (!pattern.test(user_parts[_i])) { | ||
return false; | ||
@@ -187,0 +171,0 @@ } |
import assertString from './util/assertString'; | ||
var hslcomma = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i; | ||
var hslspace = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i; | ||
var hslComma = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(,(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}(,((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?))?\)$/i; | ||
var hslSpace = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(\s(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s?(\/\s((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s?)?\)$/i; | ||
export default function isHSL(str) { | ||
assertString(str); | ||
return hslcomma.test(str) || hslspace.test(str); | ||
assertString(str); // Strip duplicate spaces before calling the validation regex (See #1598 for more info) | ||
var strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1'); | ||
if (strippedStr.indexOf(',') !== -1) { | ||
return hslComma.test(strippedStr); | ||
} | ||
return hslSpace.test(strippedStr); | ||
} |
@@ -63,2 +63,3 @@ import assertString from './util/assertString'; | ||
MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/, | ||
MZ: /^(MZ[0-9]{2})\d{21}$/, | ||
NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/, | ||
@@ -65,0 +66,0 @@ NO: /^(NO[0-9]{2})\d{11}$/, |
@@ -45,2 +45,16 @@ import assertString from './util/assertString'; | ||
}, | ||
IR: function IR(str) { | ||
if (!str.match(/^\d{10}$/)) return false; | ||
str = "0000".concat(str).substr(str.length - 6); | ||
if (parseInt(str.substr(3, 6), 10) === 0) return false; | ||
var lastNumber = parseInt(str.substr(9, 1), 10); | ||
var sum = 0; | ||
for (var i = 0; i < 9; i++) { | ||
sum += parseInt(str.substr(i, 1), 10) * (10 - i); | ||
} | ||
sum %= 11; | ||
return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum; | ||
}, | ||
IT: function IT(str) { | ||
@@ -85,2 +99,14 @@ if (str.length !== 9) return false; | ||
}, | ||
'ar-LY': function arLY(str) { | ||
// Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2 | ||
var NIN = /^(1|2)\d{11}$/; // sanitize user input | ||
var sanitized = str.trim(); // validate the data structure | ||
if (!NIN.test(sanitized)) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
'ar-TN': function arTN(str) { | ||
@@ -87,0 +113,0 @@ var DNI = /^\d{8}$/; // sanitize user input |
@@ -32,4 +32,7 @@ import assertString from './util/assertString'; | ||
var ipv4Maybe = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/; | ||
var ipv6Block = /^[0-9A-F]{1,4}$/i; | ||
var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; | ||
var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat); | ||
var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$")); | ||
var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})'; | ||
var IPv6AddressRegExp = new RegExp('^(' + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ')(%[0-9a-zA-Z-.:]{1,})?$'); | ||
export default function isIP(str) { | ||
@@ -42,4 +45,6 @@ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
return isIP(str, 4) || isIP(str, 6); | ||
} else if (version === '4') { | ||
if (!ipv4Maybe.test(str)) { | ||
} | ||
if (version === '4') { | ||
if (!IPv4AddressRegExp.test(str)) { | ||
return false; | ||
@@ -52,73 +57,6 @@ } | ||
return parts[3] <= 255; | ||
} else if (version === '6') { | ||
var addressAndZone = [str]; // ipv6 addresses could have scoped architecture | ||
// according to https://tools.ietf.org/html/rfc4007#section-11 | ||
} | ||
if (str.includes('%')) { | ||
addressAndZone = str.split('%'); | ||
if (addressAndZone.length !== 2) { | ||
// it must be just two parts | ||
return false; | ||
} | ||
if (!addressAndZone[0].includes(':')) { | ||
// the first part must be the address | ||
return false; | ||
} | ||
if (addressAndZone[1] === '') { | ||
// the second part must not be empty | ||
return false; | ||
} | ||
} | ||
var blocks = addressAndZone[0].split(':'); | ||
var foundOmissionBlock = false; // marker to indicate :: | ||
// At least some OS accept the last 32 bits of an IPv6 address | ||
// (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says | ||
// that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses, | ||
// and '::a.b.c.d' is deprecated, but also valid. | ||
var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4); | ||
var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8; | ||
if (blocks.length > expectedNumberOfBlocks) { | ||
return false; | ||
} // initial or final :: | ||
if (str === '::') { | ||
return true; | ||
} else if (str.substr(0, 2) === '::') { | ||
blocks.shift(); | ||
blocks.shift(); | ||
foundOmissionBlock = true; | ||
} else if (str.substr(str.length - 2) === '::') { | ||
blocks.pop(); | ||
blocks.pop(); | ||
foundOmissionBlock = true; | ||
} | ||
for (var i = 0; i < blocks.length; ++i) { | ||
// test for a :: which can not be at the string start/end | ||
// since those cases have been handled above | ||
if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { | ||
if (foundOmissionBlock) { | ||
return false; // multiple :: in address | ||
} | ||
foundOmissionBlock = true; | ||
} else if (foundIPv4TransitionBlock && i === blocks.length - 1) {// it has been checked before that the last | ||
// block is a valid IPv4 address | ||
} else if (!ipv6Block.test(blocks[i])) { | ||
return false; | ||
} | ||
} | ||
if (foundOmissionBlock) { | ||
return blocks.length >= 1; | ||
} | ||
return blocks.length === expectedNumberOfBlocks; | ||
if (version === '6') { | ||
return !!IPv6AddressRegExp.test(str); | ||
} | ||
@@ -125,0 +63,0 @@ |
import assertString from './util/assertString'; | ||
import isIP from './isIP'; | ||
var subnetMaybe = /^\d{1,2}$/; | ||
var subnetMaybe = /^\d{1,3}$/; | ||
var v4Subnet = 32; | ||
var v6Subnet = 128; | ||
export default function isIPRange(str) { | ||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
assertString(str); | ||
@@ -21,3 +24,25 @@ var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet | ||
return isIP(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0; | ||
var isValidIP = isIP(parts[0], version); | ||
if (!isValidIP) { | ||
return false; | ||
} // Define valid subnet according to IP's version | ||
var expectedSubnet = null; | ||
switch (String(version)) { | ||
case '4': | ||
expectedSubnet = v4Subnet; | ||
break; | ||
case '6': | ||
expectedSubnet = v6Subnet; | ||
break; | ||
default: | ||
expectedSubnet = isIP(parts[0], '6') ? v6Subnet : v4Subnet; | ||
} | ||
return parts[1] <= expectedSubnet && parts[1] >= 0; | ||
} |
import assertString from './util/assertString'; | ||
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; | ||
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; // this link details how the check digit is calculated: | ||
// https://www.isin.org/isin-format/. it is a little bit | ||
// odd in that it works with digits, not numbers. in order | ||
// to make only one pass through the ISIN characters, the | ||
// each alpha character is handled as 2 characters within | ||
// the loop. | ||
export default function isISIN(str) { | ||
@@ -10,30 +16,46 @@ assertString(str); | ||
var checksumStr = str.replace(/[A-Z]/g, function (character) { | ||
return parseInt(character, 36); | ||
}); | ||
var sum = 0; | ||
var digit; | ||
var tmpNum; | ||
var shouldDouble = true; | ||
var _double = true; | ||
var sum = 0; // convert values | ||
for (var i = checksumStr.length - 2; i >= 0; i--) { | ||
digit = checksumStr.substring(i, i + 1); | ||
tmpNum = parseInt(digit, 10); | ||
for (var i = str.length - 2; i >= 0; i--) { | ||
if (str[i] >= 'A' && str[i] <= 'Z') { | ||
var value = str[i].charCodeAt(0) - 55; | ||
var lo = value % 10; | ||
var hi = Math.trunc(value / 10); // letters have two digits, so handle the low order | ||
// and high order digits separately. | ||
if (shouldDouble) { | ||
tmpNum *= 2; | ||
for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) { | ||
var digit = _arr[_i]; | ||
if (tmpNum >= 10) { | ||
sum += tmpNum + 1; | ||
if (_double) { | ||
if (digit >= 5) { | ||
sum += 1 + (digit - 5) * 2; | ||
} else { | ||
sum += digit * 2; | ||
} | ||
} else { | ||
sum += digit; | ||
} | ||
_double = !_double; | ||
} | ||
} else { | ||
var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0); | ||
if (_double) { | ||
if (_digit >= 5) { | ||
sum += 1 + (_digit - 5) * 2; | ||
} else { | ||
sum += _digit * 2; | ||
} | ||
} else { | ||
sum += tmpNum; | ||
sum += _digit; | ||
} | ||
} else { | ||
sum += tmpNum; | ||
_double = !_double; | ||
} | ||
shouldDouble = !shouldDouble; | ||
} | ||
return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10; | ||
var check = Math.trunc((sum + 9) / 10) * 10 - sum; | ||
return +str[str.length - 1] === check; | ||
} |
@@ -1,3 +0,2 @@ | ||
import assertString from './util/assertString'; | ||
import includes from './util/includes'; // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 | ||
import assertString from './util/assertString'; // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 | ||
@@ -7,3 +6,4 @@ var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']; | ||
assertString(str); | ||
return includes(validISO31661Alpha2CountriesCodes, str.toUpperCase()); | ||
} | ||
return validISO31661Alpha2CountriesCodes.indexOf(str.toUpperCase()) >= 0; | ||
} | ||
export var CountryCodes = validISO31661Alpha2CountriesCodes; |
import assertString from './util/assertString'; | ||
var localeReg = /^[A-z]{2,4}([_-]([A-z]{4}|[\d]{3}))?([_-]([A-z]{2}|[\d]{3}))?$/; | ||
var localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/; | ||
export default function isLocale(str) { | ||
@@ -4,0 +4,0 @@ assertString(str); |
import assertString from './util/assertString'; | ||
var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var macAddressNoColons = /^([0-9a-fA-F]){12}$/; | ||
var macAddressWithHyphen = /^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var macAddressWithSpaces = /^([0-9a-fA-F][0-9a-fA-F]\s){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/; | ||
var macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/; | ||
var macAddressNoSeparators = /^([0-9a-fA-F]){12}$/; | ||
var macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/; | ||
export default function isMACAddress(str, options) { | ||
assertString(str); | ||
/** | ||
* @deprecated `no_colons` TODO: remove it in the next major | ||
*/ | ||
if (options && options.no_colons) { | ||
return macAddressNoColons.test(str); | ||
if (options && (options.no_colons || options.no_separators)) { | ||
return macAddressNoSeparators.test(str); | ||
} | ||
return macAddress.test(str) || macAddressWithHyphen.test(str) || macAddressWithSpaces.test(str) || macAddressWithDots.test(str); | ||
return macAddress.test(str) || macAddressWithDots.test(str); | ||
} |
@@ -16,2 +16,3 @@ import assertString from './util/assertString'; | ||
'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/, | ||
'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/, | ||
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, | ||
@@ -30,3 +31,3 @@ 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, | ||
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, | ||
'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/, | ||
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/, | ||
'de-LU': /^(\+352)?((6\d1)\d{6})$/, | ||
@@ -37,3 +38,3 @@ 'el-GR': /^(\+?30|0)?(69\d{8})$/, | ||
'en-GG': /^(\+?44|0)1481\d{6}$/, | ||
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/, | ||
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/, | ||
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/, | ||
@@ -51,4 +52,4 @@ 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/, | ||
'en-RW': /^(\+?250|0)?[7]\d{8}$/, | ||
'en-SG': /^(\+65)?[689]\d{7}$/, | ||
'en-SL': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, | ||
'en-SG': /^(\+65)?[3689]\d{7}$/, | ||
'en-SL': /^(\+?232|0)\d{8}$/, | ||
'en-TZ': /^(\+?255|0)?[67]\d{8}$/, | ||
@@ -62,3 +63,3 @@ 'en-UG': /^(\+?256|0)?[7]\d{8}$/, | ||
'es-BO': /^(\+?591)?(6|7)\d{7}$/, | ||
'es-CO': /^(\+?57)?([1-8]{1}|3[0-9]{2})?[2-9]{1}\d{6}$/, | ||
'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/, | ||
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/, | ||
@@ -96,3 +97,5 @@ 'es-CR': /^(\+506)?[2-8]\d{7}$/, | ||
'lt-LT': /^(\+370|8)\d{8}$/, | ||
'lv-LV': /^(\+?371)2\d{7}$/, | ||
'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/, | ||
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/, | ||
'nb-NO': /^(\+?47)?[49]\d{7}$/, | ||
@@ -106,4 +109,6 @@ 'ne-NP': /^(\+?977)?9[78]\d{8}$/, | ||
'pt-PT': /^(\+?351)?9[1236]\d{7}$/, | ||
'pt-AO': /^(\+244)\d{9}$/, | ||
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/, | ||
'ru-RU': /^(\+?7|8)?9\d{9}$/, | ||
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, | ||
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/, | ||
@@ -118,4 +123,4 @@ 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, | ||
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, | ||
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ | ||
@@ -132,2 +137,4 @@ }; | ||
phones['ga-IE'] = phones['en-IE']; | ||
phones['fr-CH'] = phones['de-CH']; | ||
phones['it-CH'] = phones['fr-CH']; | ||
export default function isMobilePhone(str, locale, options) { | ||
@@ -134,0 +141,0 @@ assertString(str); |
@@ -22,2 +22,4 @@ import assertString from './util/assertString'; | ||
// BULGARIA | ||
BR: /^[A-Z]{2}\d{6}$/, | ||
// BRAZIL | ||
BY: /^[A-Z]{2}\d{7}$/, | ||
@@ -61,2 +63,4 @@ // BELARUS | ||
// INDIA | ||
IR: /^[A-Z]\d{8}$/, | ||
// IRAN | ||
IS: /^(A)\d{7}$/, | ||
@@ -76,4 +80,10 @@ // ICELAND | ||
// LATVIA | ||
LY: /^[A-Z0-9]{8}$/, | ||
// LIBYA | ||
MT: /^\d{7}$/, | ||
// MALTA | ||
MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/, | ||
// MOZAMBIQUE | ||
MY: /^[AHK]\d{8}$/, | ||
// MALAYSIA | ||
NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/, | ||
@@ -80,0 +90,0 @@ // NETHERLANDS |
@@ -34,3 +34,3 @@ import assertString from './util/assertString'; // common patterns | ||
ID: fiveDigit, | ||
IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i, | ||
IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i, | ||
IL: /^(\d{5}|\d{7})$/, | ||
@@ -43,2 +43,3 @@ IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, | ||
KE: fiveDigit, | ||
KR: /^(\d{5}|\d{6})$/, | ||
LI: /^(948[5-9]|949[0-7])$/, | ||
@@ -45,0 +46,0 @@ LT: /^LT\-\d{5}$/, |
import assertString from './util/assertString'; | ||
var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/; | ||
var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/; | ||
export default function isSlug(str) { | ||
@@ -4,0 +4,0 @@ assertString(str); |
@@ -6,3 +6,3 @@ import merge from './util/merge'; | ||
var numberRegex = /^[0-9]$/; | ||
var symbolRegex = /^[-#!$%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/; | ||
var symbolRegex = /^[-#!$@%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/; | ||
var defaultOptions = { | ||
@@ -53,2 +53,3 @@ minLength: 8, | ||
Object.keys(charMap).forEach(function (_char2) { | ||
/* istanbul ignore else */ | ||
if (upperCaseRegex.test(_char2)) { | ||
@@ -55,0 +56,0 @@ analysis.uppercaseCount += charMap[_char2]; |
@@ -367,3 +367,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
return checksum % 11 === digits[8]; | ||
return checksum % 11 % 10 === digits[8]; | ||
} | ||
@@ -1082,2 +1082,94 @@ /* | ||
/* | ||
* pt-BR validation function | ||
* (Cadastro de Pessoas Físicas (CPF, persons) | ||
* Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities) | ||
* Both inputs will be validated | ||
*/ | ||
function ptBrCheck(tin) { | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if (tin === '') return false; | ||
if (tin.length === 11) { | ||
var _sum; | ||
var ramainder; | ||
_sum = 0; | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if ( // Reject known invalid CPFs | ||
tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false; | ||
for (var i = 1; i <= 9; i++) { | ||
_sum += parseInt(tin.substring(i - 1, i), 10) * (11 - i); | ||
} | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(9, 10), 10)) return false; | ||
_sum = 0; | ||
for (var _i8 = 1; _i8 <= 10; _i8++) { | ||
_sum += parseInt(tin.substring(_i8 - 1, _i8), 10) * (12 - _i8); | ||
} | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(10, 11), 10)) return false; | ||
return true; | ||
} | ||
if (tin.length !== 14) { | ||
return false; | ||
} | ||
if ( // Reject know invalid CNPJs | ||
tin === '00000000000000' || tin === '11111111111111' || tin === '22222222222222' || tin === '33333333333333' || tin === '44444444444444' || tin === '55555555555555' || tin === '66666666666666' || tin === '77777777777777' || tin === '88888888888888' || tin === '99999999999999') { | ||
return false; | ||
} | ||
var length = tin.length - 2; | ||
var identifiers = tin.substring(0, length); | ||
var verificators = tin.substring(length); | ||
var sum = 0; | ||
var pos = length - 7; | ||
for (var _i9 = length; _i9 >= 1; _i9--) { | ||
sum += identifiers.charAt(length - _i9) * pos; | ||
pos -= 1; | ||
if (pos < 2) { | ||
pos = 9; | ||
} | ||
} | ||
var result = sum % 11 < 2 ? 0 : 11 - sum % 11; | ||
if (result !== parseInt(verificators.charAt(0), 10)) { | ||
return false; | ||
} | ||
length += 1; | ||
identifiers = tin.substring(0, length); | ||
sum = 0; | ||
pos = length - 7; | ||
for (var _i10 = length; _i10 >= 1; _i10--) { | ||
sum += identifiers.charAt(length - _i10) * pos; | ||
pos -= 1; | ||
if (pos < 2) { | ||
pos = 9; | ||
} | ||
} | ||
result = sum % 11 < 2 ? 0 : 11 - sum % 11; | ||
if (result !== parseInt(verificators.charAt(1), 10)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
/* | ||
* pt-PT validation function | ||
@@ -1340,2 +1432,3 @@ * (Número de identificação fiscal (NIF), persons/entities) | ||
'pl-PL': /^\d{10,11}$/, | ||
'pt-BR': /^\d{11,14}$/, | ||
'pt-PT': /^\d{9}$/, | ||
@@ -1375,2 +1468,3 @@ 'ro-RO': /^\d{13}$/, | ||
'pl-PL': plPlCheck, | ||
'pt-BR': ptBrCheck, | ||
'pt-PT': ptPtCheck, | ||
@@ -1377,0 +1471,0 @@ 'ro-RO': roRoCheck, |
@@ -108,5 +108,9 @@ import assertString from './util/assertString'; | ||
if (split[0] === '' || split[0].substr(0, 1) === ':') { | ||
return false; | ||
} | ||
auth = split.shift(); | ||
if (auth.indexOf(':') === -1 || auth.indexOf(':') >= 0 && auth.split(':').length > 2) { | ||
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { | ||
return false; | ||
@@ -113,0 +117,0 @@ } |
import assertString from './util/assertString'; | ||
export var vatMatchers = { | ||
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/ | ||
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/, | ||
IT: /^(IT)?[0-9]{11}$/ | ||
}; | ||
@@ -5,0 +6,0 @@ export default function isVAT(str, countryCode) { |
@@ -5,4 +5,4 @@ import assertString from './util/assertString'; | ||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /\s+$/g; | ||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /(\s)+$/g; | ||
return str.replace(pattern, ''); | ||
} |
@@ -188,2 +188,4 @@ "use strict"; | ||
var _isLicensePlate = _interopRequireDefault(require("./lib/isLicensePlate")); | ||
var _isStrongPassword = _interopRequireDefault(require("./lib/isStrongPassword")); | ||
@@ -199,3 +201,3 @@ | ||
var version = '13.5.2'; | ||
var version = '13.6.0'; | ||
var validator = { | ||
@@ -299,2 +301,3 @@ version: version, | ||
isDate: _isDate.default, | ||
isLicensePlate: _isLicensePlate.default, | ||
isVAT: _isVAT.default | ||
@@ -301,0 +304,0 @@ }; |
@@ -15,6 +15,19 @@ "use strict"; | ||
function isAlphanumeric(str) { | ||
function isAlphanumeric(_str) { | ||
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US'; | ||
(0, _assertString.default)(str); | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
(0, _assertString.default)(_str); | ||
var str = _str; | ||
var ignore = options.ignore; | ||
if (ignore) { | ||
if (ignore instanceof RegExp) { | ||
str = str.replace(ignore, ''); | ||
} else if (typeof ignore === 'string') { | ||
str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore | ||
} else { | ||
throw new Error('ignore should be instance of a String or RegExp'); | ||
} | ||
} | ||
if (locale in _alpha.alphanumeric) { | ||
@@ -21,0 +34,0 @@ return _alpha.alphanumeric[locale].test(str); |
@@ -10,8 +10,17 @@ "use strict"; | ||
var _isISO31661Alpha = require("./isISO31661Alpha2"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var isBICReg = /^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/; | ||
// https://en.wikipedia.org/wiki/ISO_9362 | ||
var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/; | ||
function isBIC(str) { | ||
(0, _assertString.default)(str); | ||
(0, _assertString.default)(str); // toUpperCase() should be removed when a new major version goes out that changes | ||
// the regex to [A-Z] (per the spec). | ||
if (_isISO31661Alpha.CountryCodes.indexOf(str.slice(4, 6).toUpperCase()) < 0) { | ||
return false; | ||
} | ||
return isBICReg.test(str); | ||
@@ -18,0 +27,0 @@ } |
@@ -13,7 +13,13 @@ "use strict"; | ||
// supports Bech32 addresses | ||
var btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; | ||
var bech32 = /^(bc1)[a-z0-9]{25,39}$/; | ||
var base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/; | ||
function isBtcAddress(str) { | ||
(0, _assertString.default)(str); | ||
return btc.test(str); | ||
(0, _assertString.default)(str); // check for bech32 | ||
if (str.startsWith('bc1')) { | ||
return bech32.test(str); | ||
} | ||
return base58.test(str); | ||
} | ||
@@ -20,0 +26,0 @@ |
@@ -38,4 +38,3 @@ "use strict"; | ||
for (var i = 0; i < attributes.length; i++) { | ||
if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {// ok | ||
} else if (!validAttribute.test(attributes[i])) { | ||
if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) { | ||
return false; | ||
@@ -42,0 +41,0 @@ } |
@@ -17,14 +17,19 @@ "use strict"; | ||
* introduced for use on small packages. | ||
* Also EAN/UCC-14 is used for Grouping of individual | ||
* trade items above unit level(Intermediate, Carton or Pallet). | ||
* For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/ | ||
* EAN consists of: | ||
* GS1 prefix, manufacturer code, product code and check digit | ||
* Reference: https://en.wikipedia.org/wiki/International_Article_Number | ||
* Reference: https://www.gtin.info/ | ||
*/ | ||
/** | ||
* Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13 | ||
* and Regular Expression for valid EANs (EAN-8, EAN-13), | ||
* with exact numberic matching of 8 or 13 digits [0-9] | ||
* Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14 | ||
* and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14), | ||
* with exact numberic matching of 8 or 13 or 14 digits [0-9] | ||
*/ | ||
var LENGTH_EAN_8 = 8; | ||
var validEanRegex = /^(\d{8}|\d{13})$/; | ||
var LENGTH_EAN_14 = 14; | ||
var validEanRegex = /^(\d{8}|\d{13}|\d{14})$/; | ||
/** | ||
@@ -40,3 +45,3 @@ * Get position weight given: | ||
function getPositionWeightThroughLengthAndIndex(length, index) { | ||
if (length === LENGTH_EAN_8) { | ||
if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) { | ||
return index % 2 === 0 ? 3 : 1; | ||
@@ -67,3 +72,3 @@ } | ||
* Check if string is valid EAN: | ||
* Matches EAN-8/EAN-13 regex | ||
* Matches EAN-8/EAN-13/EAN-14 regex | ||
* Has valid check digit. | ||
@@ -70,0 +75,0 @@ * |
@@ -20,14 +20,2 @@ "use strict"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var default_email_options = { | ||
@@ -45,3 +33,3 @@ allow_display_name: false, | ||
var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)<(.+)>$/i; | ||
var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i; | ||
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i; | ||
@@ -63,4 +51,3 @@ var gmailUserPart = /^[a-z\d]+$/; | ||
function validateDisplayName(display_name) { | ||
var trim_quotes = display_name.match(/^"(.+)"$/i); | ||
var display_name_without_quotes = trim_quotes ? trim_quotes[1] : display_name; // display name with only spaces is not valid | ||
var display_name_without_quotes = display_name.replace(/^"(.+)"$/, '$1'); // display name with only spaces is not valid | ||
@@ -77,3 +64,3 @@ if (!display_name_without_quotes.trim()) { | ||
// must to be enclosed in double-quotes, otherwise it's not a valid display name | ||
if (!trim_quotes) { | ||
if (display_name_without_quotes === display_name) { | ||
return false; | ||
@@ -101,13 +88,10 @@ } // the quotes in display name must start with character symbol \ | ||
if (display_email) { | ||
var display_name; | ||
var display_name = display_email[1]; // Remove display name and angle brackets to get email address | ||
// Can be done in the regex but will introduce a ReDOS (See #1597 for more info) | ||
var _display_email = _slicedToArray(display_email, 3); | ||
display_name = _display_email[1]; | ||
str = _display_email[2]; | ||
// sometimes need to trim the last space to get the display name | ||
str = str.replace(display_name, '').replace(/(^<|>$)/g, ''); // sometimes need to trim the last space to get the display name | ||
// because there may be a space between display name and email address | ||
// eg. myname <address@gmail.com> | ||
// the display name is `myname` instead of `myname `, so need to trim the last space | ||
if (display_name.endsWith(' ')) { | ||
@@ -198,4 +182,4 @@ display_name = display_name.substr(0, display_name.length - 1); | ||
for (var _i2 = 0; _i2 < user_parts.length; _i2++) { | ||
if (!pattern.test(user_parts[_i2])) { | ||
for (var _i = 0; _i < user_parts.length; _i++) { | ||
if (!pattern.test(user_parts[_i])) { | ||
return false; | ||
@@ -202,0 +186,0 @@ } |
@@ -12,8 +12,15 @@ "use strict"; | ||
var hslcomma = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i; | ||
var hslspace = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i; | ||
var hslComma = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(,(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}(,((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?))?\)$/i; | ||
var hslSpace = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(\s(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s?(\/\s((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s?)?\)$/i; | ||
function isHSL(str) { | ||
(0, _assertString.default)(str); | ||
return hslcomma.test(str) || hslspace.test(str); | ||
(0, _assertString.default)(str); // Strip duplicate spaces before calling the validation regex (See #1598 for more info) | ||
var strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1'); | ||
if (strippedStr.indexOf(',') !== -1) { | ||
return hslComma.test(strippedStr); | ||
} | ||
return hslSpace.test(strippedStr); | ||
} | ||
@@ -20,0 +27,0 @@ |
@@ -72,2 +72,3 @@ "use strict"; | ||
MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/, | ||
MZ: /^(MZ[0-9]{2})\d{21}$/, | ||
NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/, | ||
@@ -74,0 +75,0 @@ NO: /^(NO[0-9]{2})\d{11}$/, |
@@ -55,2 +55,16 @@ "use strict"; | ||
}, | ||
IR: function IR(str) { | ||
if (!str.match(/^\d{10}$/)) return false; | ||
str = "0000".concat(str).substr(str.length - 6); | ||
if (parseInt(str.substr(3, 6), 10) === 0) return false; | ||
var lastNumber = parseInt(str.substr(9, 1), 10); | ||
var sum = 0; | ||
for (var i = 0; i < 9; i++) { | ||
sum += parseInt(str.substr(i, 1), 10) * (10 - i); | ||
} | ||
sum %= 11; | ||
return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum; | ||
}, | ||
IT: function IT(str) { | ||
@@ -95,2 +109,14 @@ if (str.length !== 9) return false; | ||
}, | ||
'ar-LY': function arLY(str) { | ||
// Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2 | ||
var NIN = /^(1|2)\d{11}$/; // sanitize user input | ||
var sanitized = str.trim(); // validate the data structure | ||
if (!NIN.test(sanitized)) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
'ar-TN': function arTN(str) { | ||
@@ -97,0 +123,0 @@ var DNI = /^\d{8}$/; // sanitize user input |
@@ -41,4 +41,7 @@ "use strict"; | ||
* * */ | ||
var ipv4Maybe = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/; | ||
var ipv6Block = /^[0-9A-F]{1,4}$/i; | ||
var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; | ||
var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat); | ||
var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$")); | ||
var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})'; | ||
var IPv6AddressRegExp = new RegExp('^(' + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ')(%[0-9a-zA-Z-.:]{1,})?$'); | ||
@@ -52,4 +55,6 @@ function isIP(str) { | ||
return isIP(str, 4) || isIP(str, 6); | ||
} else if (version === '4') { | ||
if (!ipv4Maybe.test(str)) { | ||
} | ||
if (version === '4') { | ||
if (!IPv4AddressRegExp.test(str)) { | ||
return false; | ||
@@ -62,73 +67,6 @@ } | ||
return parts[3] <= 255; | ||
} else if (version === '6') { | ||
var addressAndZone = [str]; // ipv6 addresses could have scoped architecture | ||
// according to https://tools.ietf.org/html/rfc4007#section-11 | ||
} | ||
if (str.includes('%')) { | ||
addressAndZone = str.split('%'); | ||
if (addressAndZone.length !== 2) { | ||
// it must be just two parts | ||
return false; | ||
} | ||
if (!addressAndZone[0].includes(':')) { | ||
// the first part must be the address | ||
return false; | ||
} | ||
if (addressAndZone[1] === '') { | ||
// the second part must not be empty | ||
return false; | ||
} | ||
} | ||
var blocks = addressAndZone[0].split(':'); | ||
var foundOmissionBlock = false; // marker to indicate :: | ||
// At least some OS accept the last 32 bits of an IPv6 address | ||
// (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says | ||
// that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses, | ||
// and '::a.b.c.d' is deprecated, but also valid. | ||
var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4); | ||
var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8; | ||
if (blocks.length > expectedNumberOfBlocks) { | ||
return false; | ||
} // initial or final :: | ||
if (str === '::') { | ||
return true; | ||
} else if (str.substr(0, 2) === '::') { | ||
blocks.shift(); | ||
blocks.shift(); | ||
foundOmissionBlock = true; | ||
} else if (str.substr(str.length - 2) === '::') { | ||
blocks.pop(); | ||
blocks.pop(); | ||
foundOmissionBlock = true; | ||
} | ||
for (var i = 0; i < blocks.length; ++i) { | ||
// test for a :: which can not be at the string start/end | ||
// since those cases have been handled above | ||
if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { | ||
if (foundOmissionBlock) { | ||
return false; // multiple :: in address | ||
} | ||
foundOmissionBlock = true; | ||
} else if (foundIPv4TransitionBlock && i === blocks.length - 1) {// it has been checked before that the last | ||
// block is a valid IPv4 address | ||
} else if (!ipv6Block.test(blocks[i])) { | ||
return false; | ||
} | ||
} | ||
if (foundOmissionBlock) { | ||
return blocks.length >= 1; | ||
} | ||
return blocks.length === expectedNumberOfBlocks; | ||
if (version === '6') { | ||
return !!IPv6AddressRegExp.test(str); | ||
} | ||
@@ -135,0 +73,0 @@ |
@@ -14,5 +14,8 @@ "use strict"; | ||
var subnetMaybe = /^\d{1,2}$/; | ||
var subnetMaybe = /^\d{1,3}$/; | ||
var v4Subnet = 32; | ||
var v6Subnet = 128; | ||
function isIPRange(str) { | ||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
(0, _assertString.default)(str); | ||
@@ -34,3 +37,25 @@ var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet | ||
return (0, _isIP.default)(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0; | ||
var isValidIP = (0, _isIP.default)(parts[0], version); | ||
if (!isValidIP) { | ||
return false; | ||
} // Define valid subnet according to IP's version | ||
var expectedSubnet = null; | ||
switch (String(version)) { | ||
case '4': | ||
expectedSubnet = v4Subnet; | ||
break; | ||
case '6': | ||
expectedSubnet = v6Subnet; | ||
break; | ||
default: | ||
expectedSubnet = (0, _isIP.default)(parts[0], '6') ? v6Subnet : v4Subnet; | ||
} | ||
return parts[1] <= expectedSubnet && parts[1] >= 0; | ||
} | ||
@@ -37,0 +62,0 @@ |
@@ -12,3 +12,8 @@ "use strict"; | ||
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; | ||
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; // this link details how the check digit is calculated: | ||
// https://www.isin.org/isin-format/. it is a little bit | ||
// odd in that it works with digits, not numbers. in order | ||
// to make only one pass through the ISIN characters, the | ||
// each alpha character is handled as 2 characters within | ||
// the loop. | ||
@@ -22,30 +27,46 @@ function isISIN(str) { | ||
var checksumStr = str.replace(/[A-Z]/g, function (character) { | ||
return parseInt(character, 36); | ||
}); | ||
var sum = 0; | ||
var digit; | ||
var tmpNum; | ||
var shouldDouble = true; | ||
var double = true; | ||
var sum = 0; // convert values | ||
for (var i = checksumStr.length - 2; i >= 0; i--) { | ||
digit = checksumStr.substring(i, i + 1); | ||
tmpNum = parseInt(digit, 10); | ||
for (var i = str.length - 2; i >= 0; i--) { | ||
if (str[i] >= 'A' && str[i] <= 'Z') { | ||
var value = str[i].charCodeAt(0) - 55; | ||
var lo = value % 10; | ||
var hi = Math.trunc(value / 10); // letters have two digits, so handle the low order | ||
// and high order digits separately. | ||
if (shouldDouble) { | ||
tmpNum *= 2; | ||
for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) { | ||
var digit = _arr[_i]; | ||
if (tmpNum >= 10) { | ||
sum += tmpNum + 1; | ||
if (double) { | ||
if (digit >= 5) { | ||
sum += 1 + (digit - 5) * 2; | ||
} else { | ||
sum += digit * 2; | ||
} | ||
} else { | ||
sum += digit; | ||
} | ||
double = !double; | ||
} | ||
} else { | ||
var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0); | ||
if (double) { | ||
if (_digit >= 5) { | ||
sum += 1 + (_digit - 5) * 2; | ||
} else { | ||
sum += _digit * 2; | ||
} | ||
} else { | ||
sum += tmpNum; | ||
sum += _digit; | ||
} | ||
} else { | ||
sum += tmpNum; | ||
double = !double; | ||
} | ||
shouldDouble = !shouldDouble; | ||
} | ||
return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10; | ||
var check = Math.trunc((sum + 9) / 10) * 10 - sum; | ||
return +str[str.length - 1] === check; | ||
} | ||
@@ -52,0 +73,0 @@ |
@@ -7,7 +7,6 @@ "use strict"; | ||
exports.default = isISO31661Alpha2; | ||
exports.CountryCodes = void 0; | ||
var _assertString = _interopRequireDefault(require("./util/assertString")); | ||
var _includes = _interopRequireDefault(require("./util/includes")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,6 +19,6 @@ | ||
(0, _assertString.default)(str); | ||
return (0, _includes.default)(validISO31661Alpha2CountriesCodes, str.toUpperCase()); | ||
return validISO31661Alpha2CountriesCodes.indexOf(str.toUpperCase()) >= 0; | ||
} | ||
module.exports = exports.default; | ||
module.exports.default = exports.default; | ||
var CountryCodes = validISO31661Alpha2CountriesCodes; | ||
exports.CountryCodes = CountryCodes; |
@@ -12,3 +12,3 @@ "use strict"; | ||
var localeReg = /^[A-z]{2,4}([_-]([A-z]{4}|[\d]{3}))?([_-]([A-z]{2}|[\d]{3}))?$/; | ||
var localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/; | ||
@@ -15,0 +15,0 @@ function isLocale(str) { |
@@ -12,16 +12,17 @@ "use strict"; | ||
var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var macAddressNoColons = /^([0-9a-fA-F]){12}$/; | ||
var macAddressWithHyphen = /^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var macAddressWithSpaces = /^([0-9a-fA-F][0-9a-fA-F]\s){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/; | ||
var macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/; | ||
var macAddressNoSeparators = /^([0-9a-fA-F]){12}$/; | ||
var macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/; | ||
function isMACAddress(str, options) { | ||
(0, _assertString.default)(str); | ||
/** | ||
* @deprecated `no_colons` TODO: remove it in the next major | ||
*/ | ||
if (options && options.no_colons) { | ||
return macAddressNoColons.test(str); | ||
if (options && (options.no_colons || options.no_separators)) { | ||
return macAddressNoSeparators.test(str); | ||
} | ||
return macAddress.test(str) || macAddressWithHyphen.test(str) || macAddressWithSpaces.test(str) || macAddressWithDots.test(str); | ||
return macAddress.test(str) || macAddressWithDots.test(str); | ||
} | ||
@@ -28,0 +29,0 @@ |
@@ -26,2 +26,3 @@ "use strict"; | ||
'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/, | ||
'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/, | ||
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, | ||
@@ -40,3 +41,3 @@ 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, | ||
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, | ||
'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/, | ||
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/, | ||
'de-LU': /^(\+352)?((6\d1)\d{6})$/, | ||
@@ -47,3 +48,3 @@ 'el-GR': /^(\+?30|0)?(69\d{8})$/, | ||
'en-GG': /^(\+?44|0)1481\d{6}$/, | ||
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/, | ||
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/, | ||
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/, | ||
@@ -61,4 +62,4 @@ 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/, | ||
'en-RW': /^(\+?250|0)?[7]\d{8}$/, | ||
'en-SG': /^(\+65)?[689]\d{7}$/, | ||
'en-SL': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, | ||
'en-SG': /^(\+65)?[3689]\d{7}$/, | ||
'en-SL': /^(\+?232|0)\d{8}$/, | ||
'en-TZ': /^(\+?255|0)?[67]\d{8}$/, | ||
@@ -72,3 +73,3 @@ 'en-UG': /^(\+?256|0)?[7]\d{8}$/, | ||
'es-BO': /^(\+?591)?(6|7)\d{7}$/, | ||
'es-CO': /^(\+?57)?([1-8]{1}|3[0-9]{2})?[2-9]{1}\d{6}$/, | ||
'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/, | ||
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/, | ||
@@ -106,3 +107,5 @@ 'es-CR': /^(\+506)?[2-8]\d{7}$/, | ||
'lt-LT': /^(\+370|8)\d{8}$/, | ||
'lv-LV': /^(\+?371)2\d{7}$/, | ||
'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/, | ||
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/, | ||
'nb-NO': /^(\+?47)?[49]\d{7}$/, | ||
@@ -116,4 +119,6 @@ 'ne-NP': /^(\+?977)?9[78]\d{8}$/, | ||
'pt-PT': /^(\+?351)?9[1236]\d{7}$/, | ||
'pt-AO': /^(\+244)\d{9}$/, | ||
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/, | ||
'ru-RU': /^(\+?7|8)?9\d{9}$/, | ||
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, | ||
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/, | ||
@@ -128,4 +133,4 @@ 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, | ||
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, | ||
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ | ||
@@ -142,2 +147,4 @@ }; | ||
phones['ga-IE'] = phones['en-IE']; | ||
phones['fr-CH'] = phones['de-CH']; | ||
phones['it-CH'] = phones['fr-CH']; | ||
@@ -144,0 +151,0 @@ function isMobilePhone(str, locale, options) { |
@@ -31,2 +31,4 @@ "use strict"; | ||
// BULGARIA | ||
BR: /^[A-Z]{2}\d{6}$/, | ||
// BRAZIL | ||
BY: /^[A-Z]{2}\d{7}$/, | ||
@@ -70,2 +72,4 @@ // BELARUS | ||
// INDIA | ||
IR: /^[A-Z]\d{8}$/, | ||
// IRAN | ||
IS: /^(A)\d{7}$/, | ||
@@ -85,4 +89,10 @@ // ICELAND | ||
// LATVIA | ||
LY: /^[A-Z0-9]{8}$/, | ||
// LIBYA | ||
MT: /^\d{7}$/, | ||
// MALTA | ||
MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/, | ||
// MOZAMBIQUE | ||
MY: /^[AHK]\d{8}$/, | ||
// MALAYSIA | ||
NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/, | ||
@@ -89,0 +99,0 @@ // NETHERLANDS |
@@ -45,3 +45,3 @@ "use strict"; | ||
ID: fiveDigit, | ||
IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i, | ||
IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i, | ||
IL: /^(\d{5}|\d{7})$/, | ||
@@ -54,2 +54,3 @@ IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, | ||
KE: fiveDigit, | ||
KR: /^(\d{5}|\d{6})$/, | ||
LI: /^(948[5-9]|949[0-7])$/, | ||
@@ -56,0 +57,0 @@ LT: /^LT\-\d{5}$/, |
@@ -12,3 +12,3 @@ "use strict"; | ||
var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/; | ||
var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/; | ||
@@ -15,0 +15,0 @@ function isSlug(str) { |
@@ -17,3 +17,3 @@ "use strict"; | ||
var numberRegex = /^[0-9]$/; | ||
var symbolRegex = /^[-#!$%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/; | ||
var symbolRegex = /^[-#!$@%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/; | ||
var defaultOptions = { | ||
@@ -64,2 +64,3 @@ minLength: 8, | ||
Object.keys(charMap).forEach(function (char) { | ||
/* istanbul ignore else */ | ||
if (upperCaseRegex.test(char)) { | ||
@@ -66,0 +67,0 @@ analysis.uppercaseCount += charMap[char]; |
@@ -384,3 +384,3 @@ "use strict"; | ||
return checksum % 11 === digits[8]; | ||
return checksum % 11 % 10 === digits[8]; | ||
} | ||
@@ -1099,2 +1099,94 @@ /* | ||
/* | ||
* pt-BR validation function | ||
* (Cadastro de Pessoas Físicas (CPF, persons) | ||
* Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities) | ||
* Both inputs will be validated | ||
*/ | ||
function ptBrCheck(tin) { | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if (tin === '') return false; | ||
if (tin.length === 11) { | ||
var _sum; | ||
var ramainder; | ||
_sum = 0; | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if ( // Reject known invalid CPFs | ||
tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false; | ||
for (var i = 1; i <= 9; i++) { | ||
_sum += parseInt(tin.substring(i - 1, i), 10) * (11 - i); | ||
} | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(9, 10), 10)) return false; | ||
_sum = 0; | ||
for (var _i8 = 1; _i8 <= 10; _i8++) { | ||
_sum += parseInt(tin.substring(_i8 - 1, _i8), 10) * (12 - _i8); | ||
} | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(10, 11), 10)) return false; | ||
return true; | ||
} | ||
if (tin.length !== 14) { | ||
return false; | ||
} | ||
if ( // Reject know invalid CNPJs | ||
tin === '00000000000000' || tin === '11111111111111' || tin === '22222222222222' || tin === '33333333333333' || tin === '44444444444444' || tin === '55555555555555' || tin === '66666666666666' || tin === '77777777777777' || tin === '88888888888888' || tin === '99999999999999') { | ||
return false; | ||
} | ||
var length = tin.length - 2; | ||
var identifiers = tin.substring(0, length); | ||
var verificators = tin.substring(length); | ||
var sum = 0; | ||
var pos = length - 7; | ||
for (var _i9 = length; _i9 >= 1; _i9--) { | ||
sum += identifiers.charAt(length - _i9) * pos; | ||
pos -= 1; | ||
if (pos < 2) { | ||
pos = 9; | ||
} | ||
} | ||
var result = sum % 11 < 2 ? 0 : 11 - sum % 11; | ||
if (result !== parseInt(verificators.charAt(0), 10)) { | ||
return false; | ||
} | ||
length += 1; | ||
identifiers = tin.substring(0, length); | ||
sum = 0; | ||
pos = length - 7; | ||
for (var _i10 = length; _i10 >= 1; _i10--) { | ||
sum += identifiers.charAt(length - _i10) * pos; | ||
pos -= 1; | ||
if (pos < 2) { | ||
pos = 9; | ||
} | ||
} | ||
result = sum % 11 < 2 ? 0 : 11 - sum % 11; | ||
if (result !== parseInt(verificators.charAt(1), 10)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
/* | ||
* pt-PT validation function | ||
@@ -1357,2 +1449,3 @@ * (Número de identificação fiscal (NIF), persons/entities) | ||
'pl-PL': /^\d{10,11}$/, | ||
'pt-BR': /^\d{11,14}$/, | ||
'pt-PT': /^\d{9}$/, | ||
@@ -1392,2 +1485,3 @@ 'ro-RO': /^\d{13}$/, | ||
'pl-PL': plPlCheck, | ||
'pt-BR': ptBrCheck, | ||
'pt-PT': ptPtCheck, | ||
@@ -1394,0 +1488,0 @@ 'ro-RO': roRoCheck, |
@@ -120,5 +120,9 @@ "use strict"; | ||
if (split[0] === '' || split[0].substr(0, 1) === ':') { | ||
return false; | ||
} | ||
auth = split.shift(); | ||
if (auth.indexOf(':') === -1 || auth.indexOf(':') >= 0 && auth.split(':').length > 2) { | ||
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { | ||
return false; | ||
@@ -125,0 +129,0 @@ } |
@@ -14,3 +14,4 @@ "use strict"; | ||
var vatMatchers = { | ||
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/ | ||
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/, | ||
IT: /^(IT)?[0-9]{11}$/ | ||
}; | ||
@@ -17,0 +18,0 @@ exports.vatMatchers = vatMatchers; |
@@ -15,3 +15,3 @@ "use strict"; | ||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /\s+$/g; | ||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /(\s)+$/g; | ||
return str.replace(pattern, ''); | ||
@@ -18,0 +18,0 @@ } |
{ | ||
"name": "validator", | ||
"description": "String validation and sanitization", | ||
"version": "13.5.2", | ||
"version": "13.6.0", | ||
"sideEffects": false, | ||
"homepage": "https://github.com/chriso/validator.js", | ||
"homepage": "https://github.com/validatorjs/validator.js", | ||
"files": [ | ||
@@ -28,14 +28,11 @@ "index.js", | ||
"contributors": [ | ||
{ | ||
"name": "Anthony Nandaa", | ||
"url": "https://github.com/profnandaa" | ||
} | ||
"Anthony Nandaa (https://github.com/profnandaa)" | ||
], | ||
"main": "index.js", | ||
"bugs": { | ||
"url": "https://github.com/chriso/validator.js/issues" | ||
"url": "https://github.com/validatorjs/validator.js/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/chriso/validator.js.git" | ||
"url": "git+https://github.com/validatorjs/validator.js.git" | ||
}, | ||
@@ -52,3 +49,3 @@ "devDependencies": { | ||
"eslint-plugin-import": "^2.11.0", | ||
"mocha": "^5.1.1", | ||
"mocha": "^6.2.3", | ||
"nyc": "^14.1.0", | ||
@@ -55,0 +52,0 @@ "rimraf": "^3.0.0", |
# validator.js | ||
[![NPM version][npm-image]][npm-url] | ||
[![Build Status](https://travis-ci.org/validatorjs/validator.js.svg?branch=master)](https://travis-ci.org/validatorjs/validator.js) | ||
[![codecov](https://codecov.io/gh/validatorjs/validator.js/branch/master/graph/badge.svg)](https://codecov.io/gh/validatorjs/validator.js) | ||
[![CI][ci-image]][ci-url] | ||
[![Coverage][codecov-image]][codecov-url] | ||
[![Downloads][downloads-image]][npm-url] | ||
[![Backers on Open Collective](https://opencollective.com/validatorjs/backers/badge.svg)](#backers) | ||
[![Sponsors on Open Collective](https://opencollective.com/validatorjs/sponsors/badge.svg)](#sponsors) | ||
[![Gitter](https://badges.gitter.im/validatorjs/community.svg)](https://gitter.im/validatorjs/community) | ||
@@ -17,3 +18,3 @@ A library of string validators and sanitizers. | ||
If you're not sure if your input is a string, coerce it using `input + ''`. | ||
Passing anything other than a string is an error. | ||
Passing anything other than a string will result in an error. | ||
@@ -85,7 +86,7 @@ ## Installation and Usage | ||
--------------------------------------- | -------------------------------------- | ||
**contains(str, seed [, options ])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false}`.<br/>`ignoreCase` specified whether the case of the substring be same or not. | ||
**contains(str, seed [, options ])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false}`.<br/>`ignoreCase` specified whether the case of the substring be same or not. | ||
**equals(str, comparison)** | check if the string matches the comparison. | ||
**isAfter(str [, date])** | check if the string is a date that's after the specified date (defaults to now). | ||
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. | ||
**isAlphanumeric(str [, locale])** | check if the string contains only letters and numbers.<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. | ||
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. | ||
**isAscii(str)** | check if the string contains ASCII chars only. | ||
@@ -107,3 +108,3 @@ **isBase32(str)** | check if a string is base32 encoded. | ||
**isEAN(str)** | check if the string is an EAN (European Article Number). | ||
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '' }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` recieves a string,then the validator will reject emails that include any of the characters in the string, in the name part. | ||
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '' }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. | ||
**isEmpty(str [, options])** | check if the string has a length of zero.<br/><br/>`options` is an object which defaults to `{ ignore_whitespace:false }`. | ||
@@ -120,3 +121,3 @@ **isEthereumAddress(str)** | check if the string is an [Ethereum](https://ethereum.org/) address using basic regex. Does not validate address checksums. | ||
**isIBAN(str)** | check if a string is a IBAN (International Bank Account Number). | ||
**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['ES', 'IN', 'IT', 'NO', 'zh-TW', 'he-IL', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.<br/><br/>Defaults to 'any'. | ||
**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['ES', 'IN', 'IT', 'IR', 'MZ', 'NO', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.<br/><br/>Defaults to 'any'. | ||
**isIMEI(str [, options]))** | check if the string is a valid IMEI number. Imei should be of format `###############` or `##-######-######-#`.<br/><br/>`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format . If allow_hyphens is set to true, the validator will validate the second format. | ||
@@ -126,3 +127,3 @@ **isIn(str, values)** | check if the string is in a array of allowed values. | ||
**isIP(str [, version])** | check if the string is an IP (version 4 or 6). | ||
**isIPRange(str)** | check if the string is an IP Range(version 4 only). | ||
**isIPRange(str [, version])** | check if the string is an IP Range (version 4 or 6). | ||
**isISBN(str [, version])** | check if the string is an ISBN (version 10 or 13). | ||
@@ -137,11 +138,12 @@ **isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier). | ||
**isJWT(str)** | check if the string is valid JWT token. | ||
**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.<br/><br/>`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format. | ||
**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.<br/><br/>`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format. | ||
**isLength(str [, options])** | check if the string's length falls in a range.<br/><br/>`options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs. | ||
**isLicensePlate(str [, locale])** | check if string matches the format of a country's license plate.<br/><br/>(locale is one of `['de-DE', 'de-LI', 'pt-PT', 'sq-AL', 'pt-BR'']` or `any`). | ||
**isLocale(str)** | check if the string is a locale | ||
**isLowercase(str)** | check if the string is lowercase. | ||
**isMACAddress(str)** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{no_colons: false}`. If `no_colons` is true, the validator will allow MAC addresses without the colons. Also, it allows the use of hyphens, spaces or dots e.g '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. | ||
**isMACAddress(str)** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{no_separators: false}`. If `no_separators` is true, the validator will allow MAC addresses without separators. Also, it allows the use of hyphens, spaces or dots e.g '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. | ||
**isMagnetURI(str)** | check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme). | ||
**isMD5(str)** | check if the string is a MD5 hash.<br/><br/>Please note that you can also use the `isHash(str, 'md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA). | ||
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format | ||
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-MA', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-CA', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`. | ||
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', ''mz-MZ', nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'pt-AO', 'ro-RO', 'ru-RU', 'si-LK' 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`. | ||
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. | ||
@@ -151,5 +153,5 @@ **isMultibyte(str)** | check if the string contains one or more multibyte chars. | ||
**isOctal(str)** | check if the string is a valid octal number. | ||
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'MT', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`. | ||
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IR', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'LY', 'MT', 'MY', 'MZ', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`. | ||
**isPort(str)** | check if the string is a valid port number. | ||
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.). | ||
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.). | ||
**isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. | ||
@@ -162,7 +164,7 @@ **isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.<br/><br/>`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false. | ||
**isStrongPassword(str [, options])** | Check if a password is strong or not. Allows for custom requirements or scoring rules. If `returnScore` is true, then the function returns an integer score for the password rather than a boolean.<br/>Default options: <br/>`{ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1, returnScore: false, pointsPerUnique: 1, pointsPerRepeat: 0.5, pointsForContainingLower: 10, pointsForContainingUpper: 10, pointsForContainingNumber: 10, pointsForContainingSymbol: 10 }` | ||
**isTaxID(str, locale)** | Check if the given value is a valid Tax Identification Number. Default locale is `en-US`.<br/><br/>More info about exact TIN support can be found in `src/lib/isTaxID.js`<br/><br/>Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-GB', 'en-IE', 'en-US', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV' 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE' ]` | ||
**isURL(str [, options])** | check if the string is an URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, disallow_auth: false }`.<br/><br/>require_protocol - if set as true isURL will return false if protocol is not present in the URL.<br/>require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.<br/>protocols - valid protocols can be modified with this option.<br/>require_host - if set as false isURL will not check if host is present in the URL.<br/>require_port - if set as true isURL will check if port is present in the URL.<br/>allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.<br/>validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length). | ||
**isTaxID(str, locale)** | Check if the given value is a valid Tax Identification Number. Default locale is `en-US`.<br/><br/>More info about exact TIN support can be found in `src/lib/isTaxID.js`<br/><br/>Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-GB', 'en-IE', 'en-US', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV' 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE' ]` | ||
**isURL(str [, options])** | check if the string is an URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, disallow_auth: false, validate_length: true }`.<br/><br/>require_protocol - if set as true isURL will return false if protocol is not present in the URL.<br/>require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.<br/>protocols - valid protocols can be modified with this option.<br/>require_host - if set as false isURL will not check if host is present in the URL.<br/>require_port - if set as true isURL will check if port is present in the URL.<br/>allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.<br/>validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length). | ||
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5). | ||
**isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars. | ||
**isVAT(str, countryCode)** | checks that the string is a [valid VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) if validation is available for the given country code matching [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). <br/><br/>Available country codes: `[ 'GB' ]`. | ||
**isVAT(str, countryCode)** | checks that the string is a [valid VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) if validation is available for the given country code matching [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). <br/><br/>Available country codes: `[ 'GB', 'IT' ]`. | ||
**isWhitelisted(str, chars)** | checks characters if they appear in the whitelist. | ||
@@ -193,3 +195,3 @@ **matches(str, pattern [, modifiers])** | check if string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`. | ||
XSS sanitization was removed from the library in [2d5d6999](https://github.com/chriso/validator.js/commit/2d5d6999541add350fb396ef02dc42ca3215049e). | ||
XSS sanitization was removed from the library in [2d5d6999](https://github.com/validatorjs/validator.js/commit/2d5d6999541add350fb396ef02dc42ca3215049e). | ||
@@ -264,5 +266,8 @@ For an alternative, have a look at Yahoo's [xss-filters library](https://github.com/yahoo/xss-filters) or at [DOMPurify](https://github.com/cure53/DOMPurify). | ||
[travis-url]: https://travis-ci.org/chriso/validator.js | ||
[travis-image]: http://img.shields.io/travis/chriso/validator.js.svg | ||
[codecov-url]: https://codecov.io/gh/validatorjs/validator.js | ||
[codecov-image]: https://codecov.io/gh/validatorjs/validator.js/branch/master/graph/badge.svg | ||
[ci-url]: https://github.com/validatorjs/validator.js/actions?query=workflow%3ACI | ||
[ci-image]: https://github.com/validatorjs/validator.js/workflows/CI/badge.svg?branch=master | ||
[amd]: http://requirejs.org/docs/whyamd.html | ||
@@ -269,0 +274,0 @@ [bower]: http://bower.io/ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
659412
208
13171
268