validator-string 13.15.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +269 -0
  3. package/es/index.js +218 -0
  4. package/es/lib/alpha.js +151 -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 +10 -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 +15 -0
  16. package/es/lib/isBase58.js +8 -0
  17. package/es/lib/isBase64.js +23 -0
  18. package/es/lib/isBefore.js +10 -0
  19. package/es/lib/isBoolean.js +15 -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 +93 -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 +165 -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 +14 -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 +13 -0
  39. package/es/lib/isHexadecimal.js +6 -0
  40. package/es/lib/isIBAN.js +171 -0
  41. package/es/lib/isIMEI.js +40 -0
  42. package/es/lib/isIP.js +58 -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/isISO15924.js +9 -0
  47. package/es/lib/isISO31661Alpha2.js +21 -0
  48. package/es/lib/isISO31661Alpha3.js +20 -0
  49. package/es/lib/isISO31661Numeric.js +8 -0
  50. package/es/lib/isISO4217.js +9 -0
  51. package/es/lib/isISO6346.js +28 -0
  52. package/es/lib/isISO6391.js +6 -0
  53. package/es/lib/isISO8601.js +42 -0
  54. package/es/lib/isISRC.js +8 -0
  55. package/es/lib/isISSN.js +19 -0
  56. package/es/lib/isIdentityCard.js +407 -0
  57. package/es/lib/isIn.js +23 -0
  58. package/es/lib/isInt.js +19 -0
  59. package/es/lib/isJSON.js +26 -0
  60. package/es/lib/isJWT.js +15 -0
  61. package/es/lib/isLatLong.js +21 -0
  62. package/es/lib/isLength.js +27 -0
  63. package/es/lib/isLicensePlate.js +58 -0
  64. package/es/lib/isLocale.js +107 -0
  65. package/es/lib/isLowercase.js +5 -0
  66. package/es/lib/isLuhnNumber.js +25 -0
  67. package/es/lib/isMACAddress.js +36 -0
  68. package/es/lib/isMD5.js +6 -0
  69. package/es/lib/isMagnetURI.js +9 -0
  70. package/es/lib/isMailtoURI.js +75 -0
  71. package/es/lib/isMimeType.js +40 -0
  72. package/es/lib/isMobilePhone.js +212 -0
  73. package/es/lib/isMongoId.js +6 -0
  74. package/es/lib/isMultibyte.js +10 -0
  75. package/es/lib/isNumeric.js +10 -0
  76. package/es/lib/isOctal.js +6 -0
  77. package/es/lib/isPassportNumber.js +145 -0
  78. package/es/lib/isPort.js +8 -0
  79. package/es/lib/isPostalCode.js +100 -0
  80. package/es/lib/isRFC3339.js +21 -0
  81. package/es/lib/isRgbColor.js +34 -0
  82. package/es/lib/isSemVer.js +14 -0
  83. package/es/lib/isSlug.js +6 -0
  84. package/es/lib/isStrongPassword.js +90 -0
  85. package/es/lib/isSurrogatePair.js +6 -0
  86. package/es/lib/isTaxID.js +1407 -0
  87. package/es/lib/isTime.js +22 -0
  88. package/es/lib/isULID.js +5 -0
  89. package/es/lib/isURL.js +241 -0
  90. package/es/lib/isUUID.js +23 -0
  91. package/es/lib/isUppercase.js +5 -0
  92. package/es/lib/isVAT.js +264 -0
  93. package/es/lib/isVariableWidth.js +7 -0
  94. package/es/lib/isWhitelisted.js +10 -0
  95. package/es/lib/ltrim.js +7 -0
  96. package/es/lib/matches.js +8 -0
  97. package/es/lib/normalizeEmail.js +131 -0
  98. package/es/lib/rtrim.js +15 -0
  99. package/es/lib/stripLow.js +7 -0
  100. package/es/lib/toBoolean.js +8 -0
  101. package/es/lib/toDate.js +6 -0
  102. package/es/lib/toFloat.js +5 -0
  103. package/es/lib/toInt.js +5 -0
  104. package/es/lib/trim.js +5 -0
  105. package/es/lib/unescape.js +8 -0
  106. package/es/lib/util/algorithms.js +79 -0
  107. package/es/lib/util/assertString.js +4 -0
  108. package/es/lib/util/checkHost.js +12 -0
  109. package/es/lib/util/includesArray.js +6 -0
  110. package/es/lib/util/includesString.js +4 -0
  111. package/es/lib/util/merge.js +14 -0
  112. package/es/lib/util/multilineRegex.js +12 -0
  113. package/es/lib/util/nullUndefinedCheck.js +3 -0
  114. package/es/lib/util/toString.js +13 -0
  115. package/es/lib/util/typeOf.js +10 -0
  116. package/es/lib/whitelist.js +5 -0
  117. package/index.js +229 -0
  118. package/lib/alpha.js +157 -0
  119. package/lib/blacklist.js +14 -0
  120. package/lib/contains.js +24 -0
  121. package/lib/equals.js +14 -0
  122. package/lib/escape.js +14 -0
  123. package/lib/isAbaRouting.js +23 -0
  124. package/lib/isAfter.js +19 -0
  125. package/lib/isAlpha.js +31 -0
  126. package/lib/isAlphanumeric.js +31 -0
  127. package/lib/isAscii.js +18 -0
  128. package/lib/isBIC.js +24 -0
  129. package/lib/isBase32.js +24 -0
  130. package/lib/isBase58.js +16 -0
  131. package/lib/isBase64.js +32 -0
  132. package/lib/isBefore.js +19 -0
  133. package/lib/isBoolean.js +24 -0
  134. package/lib/isBtcAddress.js +16 -0
  135. package/lib/isByteLength.js +27 -0
  136. package/lib/isCreditCard.js +52 -0
  137. package/lib/isCurrency.js +83 -0
  138. package/lib/isDataURI.js +40 -0
  139. package/lib/isDate.js +102 -0
  140. package/lib/isDecimal.js +31 -0
  141. package/lib/isDivisibleBy.js +15 -0
  142. package/lib/isEAN.js +78 -0
  143. package/lib/isEmail.js +174 -0
  144. package/lib/isEmpty.js +19 -0
  145. package/lib/isEthereumAddress.js +15 -0
  146. package/lib/isFQDN.js +76 -0
  147. package/lib/isFloat.js +22 -0
  148. package/lib/isFullWidth.js +14 -0
  149. package/lib/isHSL.js +22 -0
  150. package/lib/isHalfWidth.js +14 -0
  151. package/lib/isHash.js +30 -0
  152. package/lib/isHexColor.js +22 -0
  153. package/lib/isHexadecimal.js +15 -0
  154. package/lib/isIBAN.js +178 -0
  155. package/lib/isIMEI.js +49 -0
  156. package/lib/isIP.js +67 -0
  157. package/lib/isIPRange.js +50 -0
  158. package/lib/isISBN.js +56 -0
  159. package/lib/isISIN.js +64 -0
  160. package/lib/isISO15924.js +16 -0
  161. package/lib/isISO31661Alpha2.js +28 -0
  162. package/lib/isISO31661Alpha3.js +28 -0
  163. package/lib/isISO31661Numeric.js +16 -0
  164. package/lib/isISO4217.js +16 -0
  165. package/lib/isISO6346.js +35 -0
  166. package/lib/isISO6391.js +15 -0
  167. package/lib/isISO8601.js +50 -0
  168. package/lib/isISRC.js +16 -0
  169. package/lib/isISSN.js +28 -0
  170. package/lib/isIdentityCard.js +416 -0
  171. package/lib/isIn.js +32 -0
  172. package/lib/isInt.js +28 -0
  173. package/lib/isJSON.js +35 -0
  174. package/lib/isJWT.js +24 -0
  175. package/lib/isLatLong.js +30 -0
  176. package/lib/isLength.js +35 -0
  177. package/lib/isLicensePlate.js +67 -0
  178. package/lib/isLocale.js +115 -0
  179. package/lib/isLowercase.js +14 -0
  180. package/lib/isLuhnNumber.js +34 -0
  181. package/lib/isMACAddress.js +45 -0
  182. package/lib/isMD5.js +15 -0
  183. package/lib/isMagnetURI.js +18 -0
  184. package/lib/isMailtoURI.js +84 -0
  185. package/lib/isMimeType.js +48 -0
  186. package/lib/isMobilePhone.js +219 -0
  187. package/lib/isMongoId.js +15 -0
  188. package/lib/isMultibyte.js +18 -0
  189. package/lib/isNumeric.js +19 -0
  190. package/lib/isOctal.js +15 -0
  191. package/lib/isPassportNumber.js +152 -0
  192. package/lib/isPort.js +17 -0
  193. package/lib/isPostalCode.js +107 -0
  194. package/lib/isRFC3339.js +29 -0
  195. package/lib/isRgbColor.js +42 -0
  196. package/lib/isSemVer.js +22 -0
  197. package/lib/isSlug.js +15 -0
  198. package/lib/isStrongPassword.js +99 -0
  199. package/lib/isSurrogatePair.js +15 -0
  200. package/lib/isTaxID.js +1417 -0
  201. package/lib/isTime.js +31 -0
  202. package/lib/isULID.js +14 -0
  203. package/lib/isURL.js +249 -0
  204. package/lib/isUUID.js +32 -0
  205. package/lib/isUppercase.js +14 -0
  206. package/lib/isVAT.js +274 -0
  207. package/lib/isVariableWidth.js +16 -0
  208. package/lib/isWhitelisted.js +19 -0
  209. package/lib/ltrim.js +16 -0
  210. package/lib/matches.js +17 -0
  211. package/lib/normalizeEmail.js +140 -0
  212. package/lib/rtrim.js +24 -0
  213. package/lib/stripLow.js +16 -0
  214. package/lib/toBoolean.js +17 -0
  215. package/lib/toDate.js +15 -0
  216. package/lib/toFloat.js +14 -0
  217. package/lib/toInt.js +14 -0
  218. package/lib/trim.js +14 -0
  219. package/lib/unescape.js +17 -0
  220. package/lib/util/algorithms.js +88 -0
  221. package/lib/util/assertString.js +12 -0
  222. package/lib/util/checkHost.js +20 -0
  223. package/lib/util/includesArray.js +14 -0
  224. package/lib/util/includesString.js +12 -0
  225. package/lib/util/merge.js +22 -0
  226. package/lib/util/multilineRegex.js +20 -0
  227. package/lib/util/nullUndefinedCheck.js +11 -0
  228. package/lib/util/toString.js +21 -0
  229. package/lib/util/typeOf.js +18 -0
  230. package/lib/whitelist.js +14 -0
  231. package/package.json +83 -0
  232. package/validator.js +5808 -0
  233. package/validator.min.js +23 -0
package/es/lib/isIP.js ADDED
@@ -0,0 +1,58 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import assertString from './util/assertString';
3
+ /**
4
+ 11.3. Examples
5
+
6
+ The following addresses
7
+
8
+ fe80::1234 (on the 1st link of the node)
9
+ ff02::5678 (on the 5th link of the node)
10
+ ff08::9abc (on the 10th organization of the node)
11
+
12
+ would be represented as follows:
13
+
14
+ fe80::1234%1
15
+ ff02::5678%5
16
+ ff08::9abc%10
17
+
18
+ (Here we assume a natural translation from a zone index to the
19
+ <zone_id> part, where the Nth zone of any scope is translated into
20
+ "N".)
21
+
22
+ If we use interface names as <zone_id>, those addresses could also be
23
+ represented as follows:
24
+
25
+ fe80::1234%ne0
26
+ ff02::5678%pvc1.3
27
+ ff08::9abc%interface10
28
+
29
+ where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
30
+ to the 5th link, and "interface10" belongs to the 10th organization.
31
+ * * */
32
+ var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
33
+ var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
34
+ var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
35
+ var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
36
+ 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,})?$');
37
+ export default function isIP(ipAddress) {
38
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
+ assertString(ipAddress);
40
+
41
+ // accessing 'arguments' for backwards compatibility: isIP(ipAddress [, version])
42
+ // eslint-disable-next-line prefer-rest-params
43
+ var version = (_typeof(options) === 'object' ? options.version : arguments[1]) || '';
44
+ if (!version) {
45
+ return isIP(ipAddress, {
46
+ version: 4
47
+ }) || isIP(ipAddress, {
48
+ version: 6
49
+ });
50
+ }
51
+ if (version.toString() === '4') {
52
+ return IPv4AddressRegExp.test(ipAddress);
53
+ }
54
+ if (version.toString() === '6') {
55
+ return IPv6AddressRegExp.test(ipAddress);
56
+ }
57
+ return false;
58
+ }
@@ -0,0 +1,41 @@
1
+ import assertString from './util/assertString';
2
+ import isIP from './isIP';
3
+ var subnetMaybe = /^\d{1,3}$/;
4
+ var v4Subnet = 32;
5
+ var v6Subnet = 128;
6
+ export default function isIPRange(str) {
7
+ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
8
+ assertString(str);
9
+ var parts = str.split('/');
10
+
11
+ // parts[0] -> ip, parts[1] -> subnet
12
+ if (parts.length !== 2) {
13
+ return false;
14
+ }
15
+ if (!subnetMaybe.test(parts[1])) {
16
+ return false;
17
+ }
18
+
19
+ // Disallow preceding 0 i.e. 01, 02, ...
20
+ if (parts[1].length > 1 && parts[1].startsWith('0')) {
21
+ return false;
22
+ }
23
+ var isValidIP = isIP(parts[0], version);
24
+ if (!isValidIP) {
25
+ return false;
26
+ }
27
+
28
+ // Define valid subnet according to IP's version
29
+ var expectedSubnet = null;
30
+ switch (String(version)) {
31
+ case '4':
32
+ expectedSubnet = v4Subnet;
33
+ break;
34
+ case '6':
35
+ expectedSubnet = v6Subnet;
36
+ break;
37
+ default:
38
+ expectedSubnet = isIP(parts[0], '6') ? v6Subnet : v4Subnet;
39
+ }
40
+ return parts[1] <= expectedSubnet && parts[1] >= 0;
41
+ }
@@ -0,0 +1,47 @@
1
+ import assertString from './util/assertString';
2
+ var possibleIsbn10 = /^(?:[0-9]{9}X|[0-9]{10})$/;
3
+ var possibleIsbn13 = /^(?:[0-9]{13})$/;
4
+ var factor = [1, 3];
5
+ export default function isISBN(isbn, options) {
6
+ assertString(isbn);
7
+
8
+ // For backwards compatibility:
9
+ // isISBN(str [, version]), i.e. `options` could be used as argument for the legacy `version`
10
+ var version = String((options === null || options === void 0 ? void 0 : options.version) || options);
11
+ if (!(options !== null && options !== void 0 && options.version || options)) {
12
+ return isISBN(isbn, {
13
+ version: 10
14
+ }) || isISBN(isbn, {
15
+ version: 13
16
+ });
17
+ }
18
+ var sanitizedIsbn = isbn.replace(/[\s-]+/g, '');
19
+ var checksum = 0;
20
+ if (version === '10') {
21
+ if (!possibleIsbn10.test(sanitizedIsbn)) {
22
+ return false;
23
+ }
24
+ for (var i = 0; i < version - 1; i++) {
25
+ checksum += (i + 1) * sanitizedIsbn.charAt(i);
26
+ }
27
+ if (sanitizedIsbn.charAt(9) === 'X') {
28
+ checksum += 10 * 10;
29
+ } else {
30
+ checksum += 10 * sanitizedIsbn.charAt(9);
31
+ }
32
+ if (checksum % 11 === 0) {
33
+ return true;
34
+ }
35
+ } else if (version === '13') {
36
+ if (!possibleIsbn13.test(sanitizedIsbn)) {
37
+ return false;
38
+ }
39
+ for (var _i = 0; _i < 12; _i++) {
40
+ checksum += factor[_i % 2] * sanitizedIsbn.charAt(_i);
41
+ }
42
+ if (sanitizedIsbn.charAt(12) - (10 - checksum % 10) % 10 === 0) {
43
+ return true;
44
+ }
45
+ }
46
+ return false;
47
+ }
@@ -0,0 +1,55 @@
1
+ import assertString from './util/assertString';
2
+ var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
3
+
4
+ // this link details how the check digit is calculated:
5
+ // https://www.isin.org/isin-format/. it is a little bit
6
+ // odd in that it works with digits, not numbers. in order
7
+ // to make only one pass through the ISIN characters, the
8
+ // each alpha character is handled as 2 characters within
9
+ // the loop.
10
+
11
+ export default function isISIN(str) {
12
+ assertString(str);
13
+ if (!isin.test(str)) {
14
+ return false;
15
+ }
16
+ var _double = true;
17
+ var sum = 0;
18
+ // convert values
19
+ for (var i = str.length - 2; i >= 0; i--) {
20
+ if (str[i] >= 'A' && str[i] <= 'Z') {
21
+ var value = str[i].charCodeAt(0) - 55;
22
+ var lo = value % 10;
23
+ var hi = Math.trunc(value / 10);
24
+ // letters have two digits, so handle the low order
25
+ // and high order digits separately.
26
+ for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) {
27
+ var digit = _arr[_i];
28
+ if (_double) {
29
+ if (digit >= 5) {
30
+ sum += 1 + (digit - 5) * 2;
31
+ } else {
32
+ sum += digit * 2;
33
+ }
34
+ } else {
35
+ sum += digit;
36
+ }
37
+ _double = !_double;
38
+ }
39
+ } else {
40
+ var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
41
+ if (_double) {
42
+ if (_digit >= 5) {
43
+ sum += 1 + (_digit - 5) * 2;
44
+ } else {
45
+ sum += _digit * 2;
46
+ }
47
+ } else {
48
+ sum += _digit;
49
+ }
50
+ _double = !_double;
51
+ }
52
+ }
53
+ var check = Math.trunc((sum + 9) / 10) * 10 - sum;
54
+ return +str[str.length - 1] === check;
55
+ }
@@ -0,0 +1,9 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // from https://www.unicode.org/iso15924/iso15924-codes.html
4
+ var validISO15924Codes = new Set(['Adlm', 'Afak', 'Aghb', 'Ahom', 'Arab', 'Aran', 'Armi', 'Armn', 'Avst', 'Bali', 'Bamu', 'Bass', 'Batk', 'Beng', 'Bhks', 'Blis', 'Bopo', 'Brah', 'Brai', 'Bugi', 'Buhd', 'Cakm', 'Cans', 'Cari', 'Cham', 'Cher', 'Chis', 'Chrs', 'Cirt', 'Copt', 'Cpmn', 'Cprt', 'Cyrl', 'Cyrs', 'Deva', 'Diak', 'Dogr', 'Dsrt', 'Dupl', 'Egyd', 'Egyh', 'Egyp', 'Elba', 'Elym', 'Ethi', 'Gara', 'Geok', 'Geor', 'Glag', 'Gong', 'Gonm', 'Goth', 'Gran', 'Grek', 'Gujr', 'Gukh', 'Guru', 'Hanb', 'Hang', 'Hani', 'Hano', 'Hans', 'Hant', 'Hatr', 'Hebr', 'Hira', 'Hluw', 'Hmng', 'Hmnp', 'Hrkt', 'Hung', 'Inds', 'Ital', 'Jamo', 'Java', 'Jpan', 'Jurc', 'Kali', 'Kana', 'Kawi', 'Khar', 'Khmr', 'Khoj', 'Kitl', 'Kits', 'Knda', 'Kore', 'Kpel', 'Krai', 'Kthi', 'Lana', 'Laoo', 'Latf', 'Latg', 'Latn', 'Leke', 'Lepc', 'Limb', 'Lina', 'Linb', 'Lisu', 'Loma', 'Lyci', 'Lydi', 'Mahj', 'Maka', 'Mand', 'Mani', 'Marc', 'Maya', 'Medf', 'Mend', 'Merc', 'Mero', 'Mlym', 'Modi', 'Mong', 'Moon', 'Mroo', 'Mtei', 'Mult', 'Mymr', 'Nagm', 'Nand', 'Narb', 'Nbat', 'Newa', 'Nkdb', 'Nkgb', 'Nkoo', 'Nshu', 'Ogam', 'Olck', 'Onao', 'Orkh', 'Orya', 'Osge', 'Osma', 'Ougr', 'Palm', 'Pauc', 'Pcun', 'Pelm', 'Perm', 'Phag', 'Phli', 'Phlp', 'Phlv', 'Phnx', 'Plrd', 'Piqd', 'Prti', 'Psin', 'Qaaa', 'Qaab', 'Qaac', 'Qaad', 'Qaae', 'Qaaf', 'Qaag', 'Qaah', 'Qaai', 'Qaaj', 'Qaak', 'Qaal', 'Qaam', 'Qaan', 'Qaao', 'Qaap', 'Qaaq', 'Qaar', 'Qaas', 'Qaat', 'Qaau', 'Qaav', 'Qaaw', 'Qaax', 'Qaay', 'Qaaz', 'Qaba', 'Qabb', 'Qabc', 'Qabd', 'Qabe', 'Qabf', 'Qabg', 'Qabh', 'Qabi', 'Qabj', 'Qabk', 'Qabl', 'Qabm', 'Qabn', 'Qabo', 'Qabp', 'Qabq', 'Qabr', 'Qabs', 'Qabt', 'Qabu', 'Qabv', 'Qabw', 'Qabx', 'Ranj', 'Rjng', 'Rohg', 'Roro', 'Runr', 'Samr', 'Sara', 'Sarb', 'Saur', 'Sgnw', 'Shaw', 'Shrd', 'Shui', 'Sidd', 'Sidt', 'Sind', 'Sinh', 'Sogd', 'Sogo', 'Sora', 'Soyo', 'Sund', 'Sunu', 'Sylo', 'Syrc', 'Syre', 'Syrj', 'Syrn', 'Tagb', 'Takr', 'Tale', 'Talu', 'Taml', 'Tang', 'Tavt', 'Tayo', 'Telu', 'Teng', 'Tfng', 'Tglg', 'Thaa', 'Thai', 'Tibt', 'Tirh', 'Tnsa', 'Todr', 'Tols', 'Toto', 'Tutg', 'Ugar', 'Vaii', 'Visp', 'Vith', 'Wara', 'Wcho', 'Wole', 'Xpeo', 'Xsux', 'Yezi', 'Yiii', 'Zanb', 'Zinh', 'Zmth', 'Zsye', 'Zsym', 'Zxxx', 'Zyyy', 'Zzzz']);
5
+ export default function isISO15924(str) {
6
+ assertString(str);
7
+ return validISO15924Codes.has(str);
8
+ }
9
+ export var ScriptCodes = validISO15924Codes;
@@ -0,0 +1,21 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
4
+ 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']);
5
+ var alpha2CountryCode = /^[a-zA-Z]{2}$/;
6
+ export default function isISO31661Alpha2(str) {
7
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8
+ assertString(str);
9
+ var userAssignedCodes = options.userAssignedCodes;
10
+ var validUserAssignedCodes = (userAssignedCodes || []).reduce(function (accumulator, userAssignedCode) {
11
+ if (alpha2CountryCode.test(userAssignedCode)) {
12
+ accumulator.push(userAssignedCode.toUpperCase());
13
+ }
14
+ return accumulator;
15
+ }, []);
16
+ if (validUserAssignedCodes.includes(str.toUpperCase())) {
17
+ return true;
18
+ }
19
+ return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
20
+ }
21
+ export var CountryCodes = validISO31661Alpha2CountriesCodes;
@@ -0,0 +1,20 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
4
+ 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']);
5
+ var alpha3CountryCode = /^[a-zA-Z]{3}$/;
6
+ export default function isISO31661Alpha3(str) {
7
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8
+ assertString(str);
9
+ var userAssignedCodes = options.userAssignedCodes;
10
+ var validUserAssignedCodes = (userAssignedCodes || []).reduce(function (accumulator, userAssignedCode) {
11
+ if (alpha3CountryCode.test(userAssignedCode)) {
12
+ accumulator.push(userAssignedCode.toUpperCase());
13
+ }
14
+ return accumulator;
15
+ }, []);
16
+ if (validUserAssignedCodes.includes(str.toUpperCase())) {
17
+ return true;
18
+ }
19
+ return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
20
+ }
@@ -0,0 +1,8 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // from https://en.wikipedia.org/wiki/ISO_3166-1_numeric
4
+ var validISO31661NumericCountriesCodes = new Set(['004', '008', '010', '012', '016', '020', '024', '028', '031', '032', '036', '040', '044', '048', '050', '051', '052', '056', '060', '064', '068', '070', '072', '074', '076', '084', '086', '090', '092', '096', '100', '104', '108', '112', '116', '120', '124', '132', '136', '140', '144', '148', '152', '156', '158', '162', '166', '170', '174', '175', '178', '180', '184', '188', '191', '192', '196', '203', '204', '208', '212', '214', '218', '222', '226', '231', '232', '233', '234', '238', '239', '242', '246', '248', '250', '254', '258', '260', '262', '266', '268', '270', '275', '276', '288', '292', '296', '300', '304', '308', '312', '316', '320', '324', '328', '332', '334', '336', '340', '344', '348', '352', '356', '360', '364', '368', '372', '376', '380', '384', '388', '392', '398', '400', '404', '408', '410', '414', '417', '418', '422', '426', '428', '430', '434', '438', '440', '442', '446', '450', '454', '458', '462', '466', '470', '474', '478', '480', '484', '492', '496', '498', '499', '500', '504', '508', '512', '516', '520', '524', '528', '531', '533', '534', '535', '540', '548', '554', '558', '562', '566', '570', '574', '578', '580', '581', '583', '584', '585', '586', '591', '598', '600', '604', '608', '612', '616', '620', '624', '626', '630', '634', '638', '642', '643', '646', '652', '654', '659', '660', '662', '663', '666', '670', '674', '678', '682', '686', '688', '690', '694', '702', '703', '704', '705', '706', '710', '716', '724', '728', '729', '732', '740', '744', '748', '752', '756', '760', '762', '764', '768', '772', '776', '780', '784', '788', '792', '795', '796', '798', '800', '804', '807', '818', '826', '831', '832', '833', '834', '840', '850', '854', '858', '860', '862', '876', '882', '887', '894']);
5
+ export default function isISO31661Numeric(str) {
6
+ assertString(str);
7
+ return validISO31661NumericCountriesCodes.has(str);
8
+ }
@@ -0,0 +1,9 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // from https://en.wikipedia.org/wiki/ISO_4217
4
+ 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', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', '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', 'VED', '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']);
5
+ export default function isISO4217(str) {
6
+ assertString(str);
7
+ return validISO4217CurrencyCodes.has(str.toUpperCase());
8
+ }
9
+ export var CurrencyCodes = validISO4217CurrencyCodes;
@@ -0,0 +1,28 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // https://en.wikipedia.org/wiki/ISO_6346
4
+ // according to ISO6346 standard, checksum digit is mandatory for freight container but recommended
5
+ // for other container types (J and Z)
6
+ var isISO6346Str = /^[A-Z]{3}(U[0-9]{7})|([J,Z][0-9]{6,7})$/;
7
+ var isDigit = /^[0-9]$/;
8
+ export function isISO6346(str) {
9
+ assertString(str);
10
+ str = str.toUpperCase();
11
+ if (!isISO6346Str.test(str)) return false;
12
+ if (str.length === 11) {
13
+ var sum = 0;
14
+ for (var i = 0; i < str.length - 1; i++) {
15
+ if (!isDigit.test(str[i])) {
16
+ var convertedCode = void 0;
17
+ var letterCode = str.charCodeAt(i) - 55;
18
+ 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;
19
+ sum += convertedCode * Math.pow(2, i);
20
+ } else sum += str[i] * Math.pow(2, i);
21
+ }
22
+ var checkSumDigit = sum % 11;
23
+ if (checkSumDigit === 10) checkSumDigit = 0;
24
+ return Number(str[str.length - 1]) === checkSumDigit;
25
+ }
26
+ return true;
27
+ }
28
+ export var isFreightContainerID = isISO6346;
@@ -0,0 +1,6 @@
1
+ import assertString from './util/assertString';
2
+ 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']);
3
+ export default function isISO6391(str) {
4
+ assertString(str);
5
+ return isISO6391Set.has(str);
6
+ }
@@ -0,0 +1,42 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /* eslint-disable max-len */
4
+ // from http://goo.gl/0ejHHW
5
+ 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)?)?)?)?$/;
6
+ // same as above, except with a strict 'T' separator between date and time
7
+ 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)?)?)?)?$/;
8
+ /* eslint-enable max-len */
9
+ var isValidDate = function isValidDate(str) {
10
+ // str must have passed the ISO8601 check
11
+ // this check is meant to catch invalid dates
12
+ // like 2009-02-31
13
+ // first check for ordinal dates
14
+ var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
15
+ if (ordinalMatch) {
16
+ var oYear = Number(ordinalMatch[1]);
17
+ var oDay = Number(ordinalMatch[2]);
18
+ // if is leap year
19
+ if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
20
+ return oDay <= 365;
21
+ }
22
+ var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
23
+ var year = match[1];
24
+ var month = match[2];
25
+ var day = match[3];
26
+ var monthString = month ? "0".concat(month).slice(-2) : month;
27
+ var dayString = day ? "0".concat(day).slice(-2) : day;
28
+
29
+ // create a date object and compare
30
+ var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
31
+ if (month && day) {
32
+ return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
33
+ }
34
+ return true;
35
+ };
36
+ export default function isISO8601(str) {
37
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ assertString(str);
39
+ var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
40
+ if (check && options.strict) return isValidDate(str);
41
+ return check;
42
+ }
@@ -0,0 +1,8 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // see http://isrc.ifpi.org/en/isrc-standard/code-syntax
4
+ var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
5
+ export default function isISRC(str) {
6
+ assertString(str);
7
+ return isrc.test(str);
8
+ }
@@ -0,0 +1,19 @@
1
+ import assertString from './util/assertString';
2
+ var issn = '^\\d{4}-?\\d{3}[\\dX]$';
3
+ export default function isISSN(str) {
4
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5
+ assertString(str);
6
+ var testIssn = issn;
7
+ testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
8
+ testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
9
+ if (!testIssn.test(str)) {
10
+ return false;
11
+ }
12
+ var digits = str.replace('-', '').toUpperCase();
13
+ var checksum = 0;
14
+ for (var i = 0; i < digits.length; i++) {
15
+ var digit = digits[i];
16
+ checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
17
+ }
18
+ return checksum % 11 === 0;
19
+ }