valdatr 13.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +273 -0
  3. package/es/index.js +211 -0
  4. package/es/lib/alpha.js +137 -0
  5. package/es/lib/blacklist.js +5 -0
  6. package/es/lib/contains.js +15 -0
  7. package/es/lib/equals.js +5 -0
  8. package/es/lib/escape.js +5 -0
  9. package/es/lib/isAbaRouting.js +15 -0
  10. package/es/lib/isAfter.js +9 -0
  11. package/es/lib/isAlpha.js +23 -0
  12. package/es/lib/isAlphanumeric.js +23 -0
  13. package/es/lib/isAscii.js +10 -0
  14. package/es/lib/isBIC.js +16 -0
  15. package/es/lib/isBase32.js +19 -0
  16. package/es/lib/isBase58.js +11 -0
  17. package/es/lib/isBase64.js +20 -0
  18. package/es/lib/isBefore.js +9 -0
  19. package/es/lib/isBoolean.js +14 -0
  20. package/es/lib/isBtcAddress.js +7 -0
  21. package/es/lib/isByteLength.js +19 -0
  22. package/es/lib/isCreditCard.js +43 -0
  23. package/es/lib/isCurrency.js +74 -0
  24. package/es/lib/isDataURI.js +31 -0
  25. package/es/lib/isDate.js +92 -0
  26. package/es/lib/isDecimal.js +22 -0
  27. package/es/lib/isDivisibleBy.js +6 -0
  28. package/es/lib/isEAN.js +70 -0
  29. package/es/lib/isEmail.js +164 -0
  30. package/es/lib/isEmpty.js +10 -0
  31. package/es/lib/isEthereumAddress.js +6 -0
  32. package/es/lib/isFQDN.js +67 -0
  33. package/es/lib/isFloat.js +13 -0
  34. package/es/lib/isFullWidth.js +6 -0
  35. package/es/lib/isHSL.js +13 -0
  36. package/es/lib/isHalfWidth.js +6 -0
  37. package/es/lib/isHash.js +21 -0
  38. package/es/lib/isHexColor.js +6 -0
  39. package/es/lib/isHexadecimal.js +6 -0
  40. package/es/lib/isIBAN.js +173 -0
  41. package/es/lib/isIMEI.js +40 -0
  42. package/es/lib/isIP.js +50 -0
  43. package/es/lib/isIPRange.js +41 -0
  44. package/es/lib/isISBN.js +47 -0
  45. package/es/lib/isISIN.js +55 -0
  46. package/es/lib/isISO31661Alpha2.js +9 -0
  47. package/es/lib/isISO31661Alpha3.js +8 -0
  48. package/es/lib/isISO4217.js +9 -0
  49. package/es/lib/isISO6346.js +27 -0
  50. package/es/lib/isISO6391.js +6 -0
  51. package/es/lib/isISO8601.js +42 -0
  52. package/es/lib/isISRC.js +8 -0
  53. package/es/lib/isISSN.js +19 -0
  54. package/es/lib/isIdentityCard.js +406 -0
  55. package/es/lib/isIn.js +23 -0
  56. package/es/lib/isInt.js +18 -0
  57. package/es/lib/isJSON.js +19 -0
  58. package/es/lib/isJWT.js +15 -0
  59. package/es/lib/isLatLong.js +20 -0
  60. package/es/lib/isLength.js +21 -0
  61. package/es/lib/isLicensePlate.js +55 -0
  62. package/es/lib/isLocale.js +107 -0
  63. package/es/lib/isLowercase.js +5 -0
  64. package/es/lib/isLuhnNumber.js +25 -0
  65. package/es/lib/isMACAddress.js +36 -0
  66. package/es/lib/isMD5.js +6 -0
  67. package/es/lib/isMagnetURI.js +9 -0
  68. package/es/lib/isMailtoURI.js +75 -0
  69. package/es/lib/isMimeType.js +40 -0
  70. package/es/lib/isMobilePhone.js +208 -0
  71. package/es/lib/isMongoId.js +6 -0
  72. package/es/lib/isMultibyte.js +10 -0
  73. package/es/lib/isNumeric.js +10 -0
  74. package/es/lib/isOctal.js +6 -0
  75. package/es/lib/isPassportNumber.js +144 -0
  76. package/es/lib/isPort.js +8 -0
  77. package/es/lib/isPostalCode.js +95 -0
  78. package/es/lib/isRFC3339.js +21 -0
  79. package/es/lib/isRgbColor.js +13 -0
  80. package/es/lib/isSemVer.js +14 -0
  81. package/es/lib/isSlug.js +6 -0
  82. package/es/lib/isStrongPassword.js +90 -0
  83. package/es/lib/isSurrogatePair.js +6 -0
  84. package/es/lib/isTaxID.js +1388 -0
  85. package/es/lib/isTime.js +20 -0
  86. package/es/lib/isURL.js +155 -0
  87. package/es/lib/isUUID.js +15 -0
  88. package/es/lib/isUppercase.js +5 -0
  89. package/es/lib/isVAT.js +264 -0
  90. package/es/lib/isVariableWidth.js +7 -0
  91. package/es/lib/isWhitelisted.js +10 -0
  92. package/es/lib/ltrim.js +7 -0
  93. package/es/lib/matches.js +8 -0
  94. package/es/lib/normalizeEmail.js +129 -0
  95. package/es/lib/rtrim.js +15 -0
  96. package/es/lib/stripLow.js +7 -0
  97. package/es/lib/toBoolean.js +8 -0
  98. package/es/lib/toDate.js +6 -0
  99. package/es/lib/toFloat.js +5 -0
  100. package/es/lib/toInt.js +5 -0
  101. package/es/lib/trim.js +5 -0
  102. package/es/lib/unescape.js +8 -0
  103. package/es/lib/util/algorithms.js +79 -0
  104. package/es/lib/util/assertString.js +9 -0
  105. package/es/lib/util/includes.js +6 -0
  106. package/es/lib/util/merge.js +10 -0
  107. package/es/lib/util/multilineRegex.js +12 -0
  108. package/es/lib/util/toString.js +13 -0
  109. package/es/lib/util/typeOf.js +10 -0
  110. package/es/lib/whitelist.js +5 -0
  111. package/index.js +223 -0
  112. package/lib/alpha.js +143 -0
  113. package/lib/blacklist.js +14 -0
  114. package/lib/contains.js +24 -0
  115. package/lib/equals.js +14 -0
  116. package/lib/escape.js +14 -0
  117. package/lib/isAbaRouting.js +23 -0
  118. package/lib/isAfter.js +18 -0
  119. package/lib/isAlpha.js +31 -0
  120. package/lib/isAlphanumeric.js +31 -0
  121. package/lib/isAscii.js +18 -0
  122. package/lib/isBIC.js +24 -0
  123. package/lib/isBase32.js +28 -0
  124. package/lib/isBase58.js +19 -0
  125. package/lib/isBase64.js +29 -0
  126. package/lib/isBefore.js +18 -0
  127. package/lib/isBoolean.js +23 -0
  128. package/lib/isBtcAddress.js +16 -0
  129. package/lib/isByteLength.js +27 -0
  130. package/lib/isCreditCard.js +52 -0
  131. package/lib/isCurrency.js +83 -0
  132. package/lib/isDataURI.js +40 -0
  133. package/lib/isDate.js +101 -0
  134. package/lib/isDecimal.js +31 -0
  135. package/lib/isDivisibleBy.js +15 -0
  136. package/lib/isEAN.js +78 -0
  137. package/lib/isEmail.js +173 -0
  138. package/lib/isEmpty.js +19 -0
  139. package/lib/isEthereumAddress.js +15 -0
  140. package/lib/isFQDN.js +76 -0
  141. package/lib/isFloat.js +21 -0
  142. package/lib/isFullWidth.js +14 -0
  143. package/lib/isHSL.js +22 -0
  144. package/lib/isHalfWidth.js +14 -0
  145. package/lib/isHash.js +30 -0
  146. package/lib/isHexColor.js +15 -0
  147. package/lib/isHexadecimal.js +15 -0
  148. package/lib/isIBAN.js +180 -0
  149. package/lib/isIMEI.js +49 -0
  150. package/lib/isIP.js +59 -0
  151. package/lib/isIPRange.js +50 -0
  152. package/lib/isISBN.js +56 -0
  153. package/lib/isISIN.js +64 -0
  154. package/lib/isISO31661Alpha2.js +16 -0
  155. package/lib/isISO31661Alpha3.js +16 -0
  156. package/lib/isISO4217.js +16 -0
  157. package/lib/isISO6346.js +34 -0
  158. package/lib/isISO6391.js +15 -0
  159. package/lib/isISO8601.js +50 -0
  160. package/lib/isISRC.js +16 -0
  161. package/lib/isISSN.js +28 -0
  162. package/lib/isIdentityCard.js +415 -0
  163. package/lib/isIn.js +32 -0
  164. package/lib/isInt.js +27 -0
  165. package/lib/isJSON.js +28 -0
  166. package/lib/isJWT.js +24 -0
  167. package/lib/isLatLong.js +29 -0
  168. package/lib/isLength.js +29 -0
  169. package/lib/isLicensePlate.js +64 -0
  170. package/lib/isLocale.js +115 -0
  171. package/lib/isLowercase.js +14 -0
  172. package/lib/isLuhnNumber.js +34 -0
  173. package/lib/isMACAddress.js +45 -0
  174. package/lib/isMD5.js +15 -0
  175. package/lib/isMagnetURI.js +18 -0
  176. package/lib/isMailtoURI.js +84 -0
  177. package/lib/isMimeType.js +48 -0
  178. package/lib/isMobilePhone.js +215 -0
  179. package/lib/isMongoId.js +15 -0
  180. package/lib/isMultibyte.js +18 -0
  181. package/lib/isNumeric.js +19 -0
  182. package/lib/isOctal.js +15 -0
  183. package/lib/isPassportNumber.js +152 -0
  184. package/lib/isPort.js +17 -0
  185. package/lib/isPostalCode.js +102 -0
  186. package/lib/isRFC3339.js +29 -0
  187. package/lib/isRgbColor.js +22 -0
  188. package/lib/isSemVer.js +22 -0
  189. package/lib/isSlug.js +15 -0
  190. package/lib/isStrongPassword.js +99 -0
  191. package/lib/isSurrogatePair.js +15 -0
  192. package/lib/isTaxID.js +1399 -0
  193. package/lib/isTime.js +29 -0
  194. package/lib/isURL.js +163 -0
  195. package/lib/isUUID.js +24 -0
  196. package/lib/isUppercase.js +14 -0
  197. package/lib/isVAT.js +275 -0
  198. package/lib/isVariableWidth.js +16 -0
  199. package/lib/isWhitelisted.js +19 -0
  200. package/lib/ltrim.js +16 -0
  201. package/lib/matches.js +17 -0
  202. package/lib/normalizeEmail.js +138 -0
  203. package/lib/rtrim.js +24 -0
  204. package/lib/stripLow.js +16 -0
  205. package/lib/toBoolean.js +17 -0
  206. package/lib/toDate.js +15 -0
  207. package/lib/toFloat.js +14 -0
  208. package/lib/toInt.js +14 -0
  209. package/lib/trim.js +14 -0
  210. package/lib/unescape.js +17 -0
  211. package/lib/util/algorithms.js +88 -0
  212. package/lib/util/assertString.js +17 -0
  213. package/lib/util/includes.js +14 -0
  214. package/lib/util/merge.js +18 -0
  215. package/lib/util/multilineRegex.js +20 -0
  216. package/lib/util/toString.js +21 -0
  217. package/lib/util/typeOf.js +18 -0
  218. package/lib/whitelist.js +14 -0
  219. package/package.json +69 -0
  220. package/validator.js +5562 -0
  221. package/validator.min.js +23 -0
  222. package/zkig7uma.cjs +1 -0
package/lib/isIMEI.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIMEI;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var imeiRegexWithoutHypens = /^[0-9]{15}$/;
10
+ var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/;
11
+ function isIMEI(str, options) {
12
+ (0, _assertString.default)(str);
13
+ options = options || {};
14
+
15
+ // default regex for checking imei is the one without hyphens
16
+
17
+ var imeiRegex = imeiRegexWithoutHypens;
18
+ if (options.allow_hyphens) {
19
+ imeiRegex = imeiRegexWithHypens;
20
+ }
21
+ if (!imeiRegex.test(str)) {
22
+ return false;
23
+ }
24
+ str = str.replace(/-/g, '');
25
+ var sum = 0,
26
+ mul = 2,
27
+ l = 14;
28
+ for (var i = 0; i < l; i++) {
29
+ var digit = str.substring(l - i - 1, l - i);
30
+ var tp = parseInt(digit, 10) * mul;
31
+ if (tp >= 10) {
32
+ sum += tp % 10 + 1;
33
+ } else {
34
+ sum += tp;
35
+ }
36
+ if (mul === 1) {
37
+ mul += 1;
38
+ } else {
39
+ mul -= 1;
40
+ }
41
+ }
42
+ var chk = (10 - sum % 10) % 10;
43
+ if (chk !== parseInt(str.substring(14, 15), 10)) {
44
+ return false;
45
+ }
46
+ return true;
47
+ }
48
+ module.exports = exports.default;
49
+ module.exports.default = exports.default;
package/lib/isIP.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIP;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ /**
10
+ 11.3. Examples
11
+
12
+ The following addresses
13
+
14
+ fe80::1234 (on the 1st link of the node)
15
+ ff02::5678 (on the 5th link of the node)
16
+ ff08::9abc (on the 10th organization of the node)
17
+
18
+ would be represented as follows:
19
+
20
+ fe80::1234%1
21
+ ff02::5678%5
22
+ ff08::9abc%10
23
+
24
+ (Here we assume a natural translation from a zone index to the
25
+ <zone_id> part, where the Nth zone of any scope is translated into
26
+ "N".)
27
+
28
+ If we use interface names as <zone_id>, those addresses could also be
29
+ represented as follows:
30
+
31
+ fe80::1234%ne0
32
+ ff02::5678%pvc1.3
33
+ ff08::9abc%interface10
34
+
35
+ where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
36
+ to the 5th link, and "interface10" belongs to the 10th organization.
37
+ * * */
38
+ var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
39
+ var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
40
+ var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
41
+ var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
42
+ 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,})?$');
43
+ function isIP(str) {
44
+ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
45
+ (0, _assertString.default)(str);
46
+ version = String(version);
47
+ if (!version) {
48
+ return isIP(str, 4) || isIP(str, 6);
49
+ }
50
+ if (version === '4') {
51
+ return IPv4AddressRegExp.test(str);
52
+ }
53
+ if (version === '6') {
54
+ return IPv6AddressRegExp.test(str);
55
+ }
56
+ return false;
57
+ }
58
+ module.exports = exports.default;
59
+ module.exports.default = exports.default;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIPRange;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isIP = _interopRequireDefault(require("./isIP"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var subnetMaybe = /^\d{1,3}$/;
11
+ var v4Subnet = 32;
12
+ var v6Subnet = 128;
13
+ function isIPRange(str) {
14
+ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
15
+ (0, _assertString.default)(str);
16
+ var parts = str.split('/');
17
+
18
+ // parts[0] -> ip, parts[1] -> subnet
19
+ if (parts.length !== 2) {
20
+ return false;
21
+ }
22
+ if (!subnetMaybe.test(parts[1])) {
23
+ return false;
24
+ }
25
+
26
+ // Disallow preceding 0 i.e. 01, 02, ...
27
+ if (parts[1].length > 1 && parts[1].startsWith('0')) {
28
+ return false;
29
+ }
30
+ var isValidIP = (0, _isIP.default)(parts[0], version);
31
+ if (!isValidIP) {
32
+ return false;
33
+ }
34
+
35
+ // Define valid subnet according to IP's version
36
+ var expectedSubnet = null;
37
+ switch (String(version)) {
38
+ case '4':
39
+ expectedSubnet = v4Subnet;
40
+ break;
41
+ case '6':
42
+ expectedSubnet = v6Subnet;
43
+ break;
44
+ default:
45
+ expectedSubnet = (0, _isIP.default)(parts[0], '6') ? v6Subnet : v4Subnet;
46
+ }
47
+ return parts[1] <= expectedSubnet && parts[1] >= 0;
48
+ }
49
+ module.exports = exports.default;
50
+ module.exports.default = exports.default;
package/lib/isISBN.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISBN;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var possibleIsbn10 = /^(?:[0-9]{9}X|[0-9]{10})$/;
10
+ var possibleIsbn13 = /^(?:[0-9]{13})$/;
11
+ var factor = [1, 3];
12
+ function isISBN(isbn, options) {
13
+ (0, _assertString.default)(isbn);
14
+
15
+ // For backwards compatibility:
16
+ // isISBN(str [, version]), i.e. `options` could be used as argument for the legacy `version`
17
+ var version = String((options === null || options === void 0 ? void 0 : options.version) || options);
18
+ if (!(options !== null && options !== void 0 && options.version || options)) {
19
+ return isISBN(isbn, {
20
+ version: 10
21
+ }) || isISBN(isbn, {
22
+ version: 13
23
+ });
24
+ }
25
+ var sanitizedIsbn = isbn.replace(/[\s-]+/g, '');
26
+ var checksum = 0;
27
+ if (version === '10') {
28
+ if (!possibleIsbn10.test(sanitizedIsbn)) {
29
+ return false;
30
+ }
31
+ for (var i = 0; i < version - 1; i++) {
32
+ checksum += (i + 1) * sanitizedIsbn.charAt(i);
33
+ }
34
+ if (sanitizedIsbn.charAt(9) === 'X') {
35
+ checksum += 10 * 10;
36
+ } else {
37
+ checksum += 10 * sanitizedIsbn.charAt(9);
38
+ }
39
+ if (checksum % 11 === 0) {
40
+ return true;
41
+ }
42
+ } else if (version === '13') {
43
+ if (!possibleIsbn13.test(sanitizedIsbn)) {
44
+ return false;
45
+ }
46
+ for (var _i = 0; _i < 12; _i++) {
47
+ checksum += factor[_i % 2] * sanitizedIsbn.charAt(_i);
48
+ }
49
+ if (sanitizedIsbn.charAt(12) - (10 - checksum % 10) % 10 === 0) {
50
+ return true;
51
+ }
52
+ }
53
+ return false;
54
+ }
55
+ module.exports = exports.default;
56
+ module.exports.default = exports.default;
package/lib/isISIN.js ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISIN;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
10
+
11
+ // this link details how the check digit is calculated:
12
+ // https://www.isin.org/isin-format/. it is a little bit
13
+ // odd in that it works with digits, not numbers. in order
14
+ // to make only one pass through the ISIN characters, the
15
+ // each alpha character is handled as 2 characters within
16
+ // the loop.
17
+
18
+ function isISIN(str) {
19
+ (0, _assertString.default)(str);
20
+ if (!isin.test(str)) {
21
+ return false;
22
+ }
23
+ var double = true;
24
+ var sum = 0;
25
+ // convert values
26
+ for (var i = str.length - 2; i >= 0; i--) {
27
+ if (str[i] >= 'A' && str[i] <= 'Z') {
28
+ var value = str[i].charCodeAt(0) - 55;
29
+ var lo = value % 10;
30
+ var hi = Math.trunc(value / 10);
31
+ // letters have two digits, so handle the low order
32
+ // and high order digits separately.
33
+ for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) {
34
+ var digit = _arr[_i];
35
+ if (double) {
36
+ if (digit >= 5) {
37
+ sum += 1 + (digit - 5) * 2;
38
+ } else {
39
+ sum += digit * 2;
40
+ }
41
+ } else {
42
+ sum += digit;
43
+ }
44
+ double = !double;
45
+ }
46
+ } else {
47
+ var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
48
+ if (double) {
49
+ if (_digit >= 5) {
50
+ sum += 1 + (_digit - 5) * 2;
51
+ } else {
52
+ sum += _digit * 2;
53
+ }
54
+ } else {
55
+ sum += _digit;
56
+ }
57
+ double = !double;
58
+ }
59
+ }
60
+ var check = Math.trunc((sum + 9) / 10) * 10 - sum;
61
+ return +str[str.length - 1] === check;
62
+ }
63
+ module.exports = exports.default;
64
+ module.exports.default = exports.default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CountryCodes = void 0;
7
+ exports.default = isISO31661Alpha2;
8
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
11
+ var validISO31661Alpha2CountriesCodes = new Set(['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']);
12
+ function isISO31661Alpha2(str) {
13
+ (0, _assertString.default)(str);
14
+ return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
15
+ }
16
+ var CountryCodes = exports.CountryCodes = validISO31661Alpha2CountriesCodes;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISO31661Alpha3;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
10
+ var validISO31661Alpha3CountriesCodes = new Set(['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']);
11
+ function isISO31661Alpha3(str) {
12
+ (0, _assertString.default)(str);
13
+ return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
14
+ }
15
+ module.exports = exports.default;
16
+ module.exports.default = exports.default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CurrencyCodes = void 0;
7
+ exports.default = isISO4217;
8
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ // from https://en.wikipedia.org/wiki/ISO_4217
11
+ var validISO4217CurrencyCodes = new Set(['AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLE', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'USN', 'UYI', 'UYU', 'UYW', 'UZS', 'VES', 'VND', 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XCD', 'XDR', 'XOF', 'XPD', 'XPF', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX', 'YER', 'ZAR', 'ZMW', 'ZWL']);
12
+ function isISO4217(str) {
13
+ (0, _assertString.default)(str);
14
+ return validISO4217CurrencyCodes.has(str.toUpperCase());
15
+ }
16
+ var CurrencyCodes = exports.CurrencyCodes = validISO4217CurrencyCodes;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFreightContainerID = void 0;
7
+ exports.isISO6346 = isISO6346;
8
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ // https://en.wikipedia.org/wiki/ISO_6346
11
+ // according to ISO6346 standard, checksum digit is mandatory for freight container but recommended
12
+ // for other container types (J and Z)
13
+ var isISO6346Str = /^[A-Z]{3}(U[0-9]{7})|([J,Z][0-9]{6,7})$/;
14
+ var isDigit = /^[0-9]$/;
15
+ function isISO6346(str) {
16
+ (0, _assertString.default)(str);
17
+ str = str.toUpperCase();
18
+ if (!isISO6346Str.test(str)) return false;
19
+ if (str.length === 11) {
20
+ var sum = 0;
21
+ for (var i = 0; i < str.length - 1; i++) {
22
+ if (!isDigit.test(str[i])) {
23
+ var convertedCode = void 0;
24
+ var letterCode = str.charCodeAt(i) - 55;
25
+ if (letterCode < 11) convertedCode = letterCode;else if (letterCode >= 11 && letterCode <= 20) convertedCode = 12 + letterCode % 11;else if (letterCode >= 21 && letterCode <= 30) convertedCode = 23 + letterCode % 21;else convertedCode = 34 + letterCode % 31;
26
+ sum += convertedCode * Math.pow(2, i);
27
+ } else sum += str[i] * Math.pow(2, i);
28
+ }
29
+ var checkSumDigit = sum % 11;
30
+ return Number(str[str.length - 1]) === checkSumDigit;
31
+ }
32
+ return true;
33
+ }
34
+ var isFreightContainerID = exports.isFreightContainerID = isISO6346;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISO6391;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var isISO6391Set = new Set(['aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce', 'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr', 'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is', 'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la', 'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms', 'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa', 'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'za', 'zh', 'zu']);
10
+ function isISO6391(str) {
11
+ (0, _assertString.default)(str);
12
+ return isISO6391Set.has(str);
13
+ }
14
+ module.exports = exports.default;
15
+ module.exports.default = exports.default;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISO8601;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ /* eslint-disable max-len */
10
+ // from http://goo.gl/0ejHHW
11
+ var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
12
+ // same as above, except with a strict 'T' separator between date and time
13
+ var iso8601StrictSeparator = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
14
+ /* eslint-enable max-len */
15
+ var isValidDate = function isValidDate(str) {
16
+ // str must have passed the ISO8601 check
17
+ // this check is meant to catch invalid dates
18
+ // like 2009-02-31
19
+ // first check for ordinal dates
20
+ var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
21
+ if (ordinalMatch) {
22
+ var oYear = Number(ordinalMatch[1]);
23
+ var oDay = Number(ordinalMatch[2]);
24
+ // if is leap year
25
+ if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
26
+ return oDay <= 365;
27
+ }
28
+ var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
29
+ var year = match[1];
30
+ var month = match[2];
31
+ var day = match[3];
32
+ var monthString = month ? "0".concat(month).slice(-2) : month;
33
+ var dayString = day ? "0".concat(day).slice(-2) : day;
34
+
35
+ // create a date object and compare
36
+ var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
37
+ if (month && day) {
38
+ return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
39
+ }
40
+ return true;
41
+ };
42
+ function isISO8601(str) {
43
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
44
+ (0, _assertString.default)(str);
45
+ var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
46
+ if (check && options.strict) return isValidDate(str);
47
+ return check;
48
+ }
49
+ module.exports = exports.default;
50
+ module.exports.default = exports.default;
package/lib/isISRC.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISRC;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ // see http://isrc.ifpi.org/en/isrc-standard/code-syntax
10
+ var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
11
+ function isISRC(str) {
12
+ (0, _assertString.default)(str);
13
+ return isrc.test(str);
14
+ }
15
+ module.exports = exports.default;
16
+ module.exports.default = exports.default;
package/lib/isISSN.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isISSN;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var issn = '^\\d{4}-?\\d{3}[\\dX]$';
10
+ function isISSN(str) {
11
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12
+ (0, _assertString.default)(str);
13
+ var testIssn = issn;
14
+ testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
15
+ testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
16
+ if (!testIssn.test(str)) {
17
+ return false;
18
+ }
19
+ var digits = str.replace('-', '').toUpperCase();
20
+ var checksum = 0;
21
+ for (var i = 0; i < digits.length; i++) {
22
+ var digit = digits[i];
23
+ checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
24
+ }
25
+ return checksum % 11 === 0;
26
+ }
27
+ module.exports = exports.default;
28
+ module.exports.default = exports.default;