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/lib/isIn.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIn;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _toString = _interopRequireDefault(require("./util/toString"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ 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); }
11
+ function isIn(str, options) {
12
+ (0, _assertString.default)(str);
13
+ var i;
14
+ if (Object.prototype.toString.call(options) === '[object Array]') {
15
+ var array = [];
16
+ for (i in options) {
17
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
18
+ // istanbul ignore else
19
+ if ({}.hasOwnProperty.call(options, i)) {
20
+ array[i] = (0, _toString.default)(options[i]);
21
+ }
22
+ }
23
+ return array.indexOf(str) >= 0;
24
+ } else if (_typeof(options) === 'object') {
25
+ return options.hasOwnProperty(str);
26
+ } else if (options && typeof options.indexOf === 'function') {
27
+ return options.indexOf(str) >= 0;
28
+ }
29
+ return false;
30
+ }
31
+ module.exports = exports.default;
32
+ module.exports.default = exports.default;
package/lib/isInt.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isInt;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _nullUndefinedCheck = _interopRequireDefault(require("./util/nullUndefinedCheck"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
11
+ var intLeadingZeroes = /^[-+]?[0-9]+$/;
12
+ function isInt(str, options) {
13
+ (0, _assertString.default)(str);
14
+ options = options || {};
15
+
16
+ // Get the regex to use for testing, based on whether
17
+ // leading zeroes are allowed or not.
18
+ var regex = options.allow_leading_zeroes === false ? int : intLeadingZeroes;
19
+
20
+ // Check min/max/lt/gt
21
+ var minCheckPassed = !options.hasOwnProperty('min') || (0, _nullUndefinedCheck.default)(options.min) || str >= options.min;
22
+ var maxCheckPassed = !options.hasOwnProperty('max') || (0, _nullUndefinedCheck.default)(options.max) || str <= options.max;
23
+ var ltCheckPassed = !options.hasOwnProperty('lt') || (0, _nullUndefinedCheck.default)(options.lt) || str < options.lt;
24
+ var gtCheckPassed = !options.hasOwnProperty('gt') || (0, _nullUndefinedCheck.default)(options.gt) || str > options.gt;
25
+ return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
26
+ }
27
+ module.exports = exports.default;
28
+ module.exports.default = exports.default;
package/lib/isJSON.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isJSON;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _includesArray = _interopRequireDefault(require("./util/includesArray"));
9
+ var _merge = _interopRequireDefault(require("./util/merge"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ 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); }
12
+ var default_json_options = {
13
+ allow_primitives: false,
14
+ allow_any_value: false
15
+ };
16
+ function isJSON(str, options) {
17
+ (0, _assertString.default)(str);
18
+ try {
19
+ options = (0, _merge.default)(options, default_json_options);
20
+ var obj = JSON.parse(str);
21
+
22
+ // When allow_any_value is true, accept anything that JSON.parse successfully parses
23
+ if (options.allow_any_value) {
24
+ return true;
25
+ }
26
+ var primitives = [];
27
+ if (options.allow_primitives) {
28
+ primitives = [null, false, true];
29
+ }
30
+ return (0, _includesArray.default)(primitives, obj) || !!obj && _typeof(obj) === 'object';
31
+ } catch (e) {/* ignore */}
32
+ return false;
33
+ }
34
+ module.exports = exports.default;
35
+ module.exports.default = exports.default;
package/lib/isJWT.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isJWT;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isBase = _interopRequireDefault(require("./isBase64"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function isJWT(str) {
11
+ (0, _assertString.default)(str);
12
+ var dotSplit = str.split('.');
13
+ var len = dotSplit.length;
14
+ if (len !== 3) {
15
+ return false;
16
+ }
17
+ return dotSplit.reduce(function (acc, currElem) {
18
+ return acc && (0, _isBase.default)(currElem, {
19
+ urlSafe: true
20
+ });
21
+ }, true);
22
+ }
23
+ module.exports = exports.default;
24
+ module.exports.default = exports.default;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLatLong;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _merge = _interopRequireDefault(require("./util/merge"));
9
+ var _includesString = _interopRequireDefault(require("./util/includesString"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
12
+ var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
13
+ var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
14
+ var longDMS = /^\s*([1-7]?\d{1,2}\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|180\D+0\D+0)\D+[EWew]?$/i;
15
+ var defaultLatLongOptions = {
16
+ checkDMS: false
17
+ };
18
+ function isLatLong(str, options) {
19
+ (0, _assertString.default)(str);
20
+ options = (0, _merge.default)(options, defaultLatLongOptions);
21
+ if (!(0, _includesString.default)(str, ',')) return false;
22
+ var pair = str.split(',');
23
+ if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
24
+ if (options.checkDMS) {
25
+ return latDMS.test(pair[0]) && longDMS.test(pair[1]);
26
+ }
27
+ return lat.test(pair[0]) && long.test(pair[1]);
28
+ }
29
+ module.exports = exports.default;
30
+ module.exports.default = exports.default;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLength;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ 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); }
10
+ /* eslint-disable prefer-rest-params */
11
+ function isLength(str, options) {
12
+ (0, _assertString.default)(str);
13
+ var min;
14
+ var max;
15
+ if (_typeof(options) === 'object') {
16
+ min = options.min || 0;
17
+ max = options.max;
18
+ } else {
19
+ // backwards compatibility: isLength(str, min [, max])
20
+ min = arguments[1] || 0;
21
+ max = arguments[2];
22
+ }
23
+ var presentationSequences = str.match(/[^\uFE0F\uFE0E][\uFE0F\uFE0E]/g) || [];
24
+ var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
25
+ var len = str.length - presentationSequences.length - surrogatePairs.length;
26
+ var isInsideRange = len >= min && (typeof max === 'undefined' || len <= max);
27
+ if (isInsideRange && Array.isArray(options === null || options === void 0 ? void 0 : options.discreteLengths)) {
28
+ return options.discreteLengths.some(function (discreteLen) {
29
+ return discreteLen === len;
30
+ });
31
+ }
32
+ return isInsideRange;
33
+ }
34
+ module.exports = exports.default;
35
+ module.exports.default = exports.default;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLicensePlate;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var validators = {
10
+ 'cs-CZ': function csCZ(str) {
11
+ return /^(([ABCDEFHIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
12
+ },
13
+ 'de-DE': function deDE(str) {
14
+ return /^((A|AA|AB|AC|AE|AH|AK|AM|AN|AÖ|AP|AS|AT|AU|AW|AZ|B|BA|BB|BC|BE|BF|BH|BI|BK|BL|BM|BN|BO|BÖ|BS|BT|BZ|C|CA|CB|CE|CO|CR|CW|D|DA|DD|DE|DH|DI|DL|DM|DN|DO|DU|DW|DZ|E|EA|EB|ED|EE|EF|EG|EH|EI|EL|EM|EN|ER|ES|EU|EW|F|FB|FD|FF|FG|FI|FL|FN|FO|FR|FS|FT|FÜ|FW|FZ|G|GA|GC|GD|GE|GF|GG|GI|GK|GL|GM|GN|GÖ|GP|GR|GS|GT|GÜ|GV|GW|GZ|H|HA|HB|HC|HD|HE|HF|HG|HH|HI|HK|HL|HM|HN|HO|HP|HR|HS|HU|HV|HX|HY|HZ|IK|IL|IN|IZ|J|JE|JL|K|KA|KB|KC|KE|KF|KG|KH|KI|KK|KL|KM|KN|KO|KR|KS|KT|KU|KW|KY|L|LA|LB|LC|LD|LF|LG|LH|LI|LL|LM|LN|LÖ|LP|LR|LU|M|MA|MB|MC|MD|ME|MG|MH|MI|MK|ML|MM|MN|MO|MQ|MR|MS|MÜ|MW|MY|MZ|N|NB|ND|NE|NF|NH|NI|NK|NM|NÖ|NP|NR|NT|NU|NW|NY|NZ|OA|OB|OC|OD|OE|OF|OG|OH|OK|OL|OP|OS|OZ|P|PA|PB|PE|PF|PI|PL|PM|PN|PR|PS|PW|PZ|R|RA|RC|RD|RE|RG|RH|RI|RL|RM|RN|RO|RP|RS|RT|RU|RV|RW|RZ|S|SB|SC|SE|SG|SI|SK|SL|SM|SN|SO|SP|SR|ST|SU|SW|SY|SZ|TE|TF|TG|TO|TP|TR|TS|TT|TÜ|ÜB|UE|UH|UL|UM|UN|V|VB|VG|VK|VR|VS|W|WA|WB|WE|WF|WI|WK|WL|WM|WN|WO|WR|WS|WT|WÜ|WW|WZ|Z|ZE|ZI|ZP|ZR|ZW|ZZ)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(ABG|ABI|AIB|AIC|ALF|ALZ|ANA|ANG|ANK|APD|ARN|ART|ASL|ASZ|AUR|AZE|BAD|BAR|BBG|BCH|BED|BER|BGD|BGL|BID|BIN|BIR|BIT|BIW|BKS|BLB|BLK|BNA|BOG|BOH|BOR|BOT|BRA|BRB|BRG|BRK|BRL|BRV|BSB|BSK|BTF|BÜD|BUL|BÜR|BÜS|BÜZ|CAS|CHA|CLP|CLZ|COC|COE|CUX|DAH|DAN|DAU|DBR|DEG|DEL|DGF|DIL|DIN|DIZ|DKB|DLG|DON|DUD|DÜW|EBE|EBN|EBS|ECK|EIC|EIL|EIN|EIS|EMD|EMS|ERB|ERH|ERK|ERZ|ESB|ESW|FDB|FDS|FEU|FFB|FKB|FLÖ|FOR|FRG|FRI|FRW|FTL|FÜS|GAN|GAP|GDB|GEL|GEO|GER|GHA|GHC|GLA|GMN|GNT|GOA|GOH|GRA|GRH|GRI|GRM|GRZ|GTH|GUB|GUN|GVM|HAB|HAL|HAM|HAS|HBN|HBS|HCH|HDH|HDL|HEB|HEF|HEI|HER|HET|HGN|HGW|HHM|HIG|HIP|HMÜ|HOG|HOH|HOL|HOM|HOR|HÖS|HOT|HRO|HSK|HST|HVL|HWI|IGB|ILL|JÜL|KEH|KEL|KEM|KIB|KLE|KLZ|KÖN|KÖT|KÖZ|KRU|KÜN|KUS|KYF|LAN|LAU|LBS|LBZ|LDK|LDS|LEO|LER|LEV|LIB|LIF|LIP|LÖB|LOS|LRO|LSZ|LÜN|LUP|LWL|MAB|MAI|MAK|MAL|MED|MEG|MEI|MEK|MEL|MER|MET|MGH|MGN|MHL|MIL|MKK|MOD|MOL|MON|MOS|MSE|MSH|MSP|MST|MTK|MTL|MÜB|MÜR|MYK|MZG|NAB|NAI|NAU|NDH|NEA|NEB|NEC|NEN|NES|NEW|NMB|NMS|NOH|NOL|NOM|NOR|NVP|NWM|OAL|OBB|OBG|OCH|OHA|ÖHR|OHV|OHZ|OPR|OSL|OVI|OVL|OVP|PAF|PAN|PAR|PCH|PEG|PIR|PLÖ|PRÜ|QFT|QLB|RDG|REG|REH|REI|RID|RIE|ROD|ROF|ROK|ROL|ROS|ROT|ROW|RSL|RÜD|RÜG|SAB|SAD|SAN|SAW|SBG|SBK|SCZ|SDH|SDL|SDT|SEB|SEE|SEF|SEL|SFB|SFT|SGH|SHA|SHG|SHK|SHL|SIG|SIM|SLE|SLF|SLK|SLN|SLS|SLÜ|SLZ|SMÜ|SOB|SOG|SOK|SÖM|SON|SPB|SPN|SRB|SRO|STA|STB|STD|STE|STL|SUL|SÜW|SWA|SZB|TBB|TDO|TET|TIR|TÖL|TUT|UEM|UER|UFF|USI|VAI|VEC|VER|VIB|VIE|VIT|VOH|WAF|WAK|WAN|WAR|WAT|WBS|WDA|WEL|WEN|WER|WES|WHV|WIL|WIS|WIT|WIZ|WLG|WMS|WND|WOB|WOH|WOL|WOR|WOS|WRN|WSF|WST|WSW|WTL|WTM|WUG|WÜM|WUN|WUR|WZL|ZEL|ZIG)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str);
15
+ },
16
+ 'de-LI': function deLI(str) {
17
+ return /^FL[- ]?\d{1,5}[UZ]?$/.test(str);
18
+ },
19
+ 'en-IN': function enIN(str) {
20
+ return /^[A-Z]{2}[ -]?[0-9]{1,2}(?:[ -]?[A-Z])(?:[ -]?[A-Z]*)?[ -]?[0-9]{4}$/.test(str);
21
+ },
22
+ 'en-SG': function enSG(str) {
23
+ return /^[A-Z]{3}[ -]?[\d]{4}[ -]?[A-Z]{1}$/.test(str);
24
+ },
25
+ 'es-AR': function esAR(str) {
26
+ return /^(([A-Z]{2} ?[0-9]{3} ?[A-Z]{2})|([A-Z]{3} ?[0-9]{3}))$/.test(str);
27
+ },
28
+ 'fi-FI': function fiFI(str) {
29
+ return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str);
30
+ },
31
+ 'hu-HU': function huHU(str) {
32
+ return /^((((?!AAA)(([A-NPRSTVZWXY]{1})([A-PR-Z]{1})([A-HJ-NPR-Z]))|(A[ABC]I)|A[ABC]O|A[A-W]Q|BPI|BPO|UCO|UDO|XAO)-(?!000)\d{3})|(M\d{6})|((CK|DT|CD|HC|H[ABEFIKLMNPRSTVX]|MA|OT|R[A-Z]) \d{2}-\d{2})|(CD \d{3}-\d{3})|(C-(C|X) \d{4})|(X-(A|B|C) \d{4})|(([EPVZ]-\d{5}))|(S A[A-Z]{2} \d{2})|(SP \d{2}-\d{2}))$/.test(str);
33
+ },
34
+ 'pt-BR': function ptBR(str) {
35
+ return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
36
+ },
37
+ 'pt-PT': function ptPT(str) {
38
+ return /^(([A-Z]{2}[ -·]?[0-9]{2}[ -·]?[0-9]{2})|([0-9]{2}[ -·]?[A-Z]{2}[ -·]?[0-9]{2})|([0-9]{2}[ -·]?[0-9]{2}[ -·]?[A-Z]{2})|([A-Z]{2}[ -·]?[0-9]{2}[ -·]?[A-Z]{2}))$/.test(str);
39
+ },
40
+ 'sq-AL': function sqAL(str) {
41
+ return /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str);
42
+ },
43
+ 'sv-SE': function svSE(str) {
44
+ return /^[A-HJ-PR-UW-Z]{3} ?[\d]{2}[A-HJ-PR-UW-Z1-9]$|(^[A-ZÅÄÖ ]{2,7}$)/.test(str.trim());
45
+ },
46
+ 'en-PK': function enPK(str) {
47
+ return /(^[A-Z]{2}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{3}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{4}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]((\s|-){0,1})[0-9]{4}((\s|-)[0-9]{2}){0,1}$)/.test(str.trim());
48
+ }
49
+ };
50
+ function isLicensePlate(str, locale) {
51
+ (0, _assertString.default)(str);
52
+ if (locale in validators) {
53
+ return validators[locale](str);
54
+ } else if (locale === 'any') {
55
+ for (var key in validators) {
56
+ /* eslint guard-for-in: 0 */
57
+ var validator = validators[key];
58
+ if (validator(str)) {
59
+ return true;
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+ throw new Error("Invalid locale '".concat(locale, "'"));
65
+ }
66
+ module.exports = exports.default;
67
+ module.exports.default = exports.default;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLocale;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ /*
10
+ = 3ALPHA ; selected ISO 639 codes
11
+ *2("-" 3ALPHA) ; permanently reserved
12
+ */
13
+ var extlang = '([A-Za-z]{3}(-[A-Za-z]{3}){0,2})';
14
+
15
+ /*
16
+ = 2*3ALPHA ; shortest ISO 639 code
17
+ ["-" extlang] ; sometimes followed by
18
+ ; extended language subtags
19
+ / 4ALPHA ; or reserved for future use
20
+ / 5*8ALPHA ; or registered language subtag
21
+ */
22
+ var language = "(([a-zA-Z]{2,3}(-".concat(extlang, ")?)|([a-zA-Z]{5,8}))");
23
+
24
+ /*
25
+ = 4ALPHA ; ISO 15924 code
26
+ */
27
+ var script = '([A-Za-z]{4})';
28
+
29
+ /*
30
+ = 2ALPHA ; ISO 3166-1 code
31
+ / 3DIGIT ; UN M.49 code
32
+ */
33
+ var region = '([A-Za-z]{2}|\\d{3})';
34
+
35
+ /*
36
+ = 5*8alphanum ; registered variants
37
+ / (DIGIT 3alphanum)
38
+ */
39
+ var variant = '([A-Za-z0-9]{5,8}|(\\d[A-Z-a-z0-9]{3}))';
40
+
41
+ /*
42
+ = DIGIT ; 0 - 9
43
+ / %x41-57 ; A - W
44
+ / %x59-5A ; Y - Z
45
+ / %x61-77 ; a - w
46
+ / %x79-7A ; y - z
47
+ */
48
+ var singleton = '(\\d|[A-W]|[Y-Z]|[a-w]|[y-z])';
49
+
50
+ /*
51
+ = singleton 1*("-" (2*8alphanum))
52
+ ; Single alphanumerics
53
+ ; "x" reserved for private use
54
+ */
55
+ var extension = "(".concat(singleton, "(-[A-Za-z0-9]{2,8})+)");
56
+
57
+ /*
58
+ = "x" 1*("-" (1*8alphanum))
59
+ */
60
+ var privateuse = '(x(-[A-Za-z0-9]{1,8})+)';
61
+
62
+ // irregular tags do not match the 'langtag' production and would not
63
+ // otherwise be considered 'well-formed'. These tags are all valid, but
64
+ // most are deprecated in favor of more modern subtags or subtag combination
65
+
66
+ var irregular = '((en-GB-oed)|(i-ami)|(i-bnn)|(i-default)|(i-enochian)|' + '(i-hak)|(i-klingon)|(i-lux)|(i-mingo)|(i-navajo)|(i-pwn)|(i-tao)|' + '(i-tay)|(i-tsu)|(sgn-BE-FR)|(sgn-BE-NL)|(sgn-CH-DE))';
67
+
68
+ // regular tags match the 'langtag' production, but their subtags are not
69
+ // extended language or variant subtags: their meaning is defined by
70
+ // their registration and all of these are deprecated in favor of a more
71
+ // modern subtag or sequence of subtags
72
+
73
+ var regular = '((art-lojban)|(cel-gaulish)|(no-bok)|(no-nyn)|(zh-guoyu)|' + '(zh-hakka)|(zh-min)|(zh-min-nan)|(zh-xiang))';
74
+
75
+ /*
76
+ = irregular ; non-redundant tags registered
77
+ / regular ; during the RFC 3066 era
78
+
79
+ */
80
+ var grandfathered = "(".concat(irregular, "|").concat(regular, ")");
81
+
82
+ /*
83
+ RFC 5646 defines delimitation of subtags via a hyphen:
84
+
85
+ "Subtag" refers to a specific section of a tag, delimited by a
86
+ hyphen, such as the subtags 'zh', 'Hant', and 'CN' in the tag "zh-
87
+ Hant-CN". Examples of subtags in this document are enclosed in
88
+ single quotes ('Hant')
89
+
90
+ However, we need to add "_" to maintain the existing behaviour.
91
+ */
92
+ var delimiter = '(-|_)';
93
+
94
+ /*
95
+ = language
96
+ ["-" script]
97
+ ["-" region]
98
+ *("-" variant)
99
+ *("-" extension)
100
+ ["-" privateuse]
101
+ */
102
+ var langtag = "".concat(language, "(").concat(delimiter).concat(script, ")?(").concat(delimiter).concat(region, ")?(").concat(delimiter).concat(variant, ")*(").concat(delimiter).concat(extension, ")*(").concat(delimiter).concat(privateuse, ")?");
103
+
104
+ /*
105
+ Regex implementation based on BCP RFC 5646
106
+ Tags for Identifying Languages
107
+ https://www.rfc-editor.org/rfc/rfc5646.html
108
+ */
109
+ var languageTagRegex = new RegExp("(^".concat(privateuse, "$)|(^").concat(grandfathered, "$)|(^").concat(langtag, "$)"));
110
+ function isLocale(str) {
111
+ (0, _assertString.default)(str);
112
+ return languageTagRegex.test(str);
113
+ }
114
+ module.exports = exports.default;
115
+ module.exports.default = exports.default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLowercase;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function isLowercase(str) {
10
+ (0, _assertString.default)(str);
11
+ return str === str.toLowerCase();
12
+ }
13
+ module.exports = exports.default;
14
+ module.exports.default = exports.default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLuhnNumber;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function isLuhnNumber(str) {
10
+ (0, _assertString.default)(str);
11
+ var sanitized = str.replace(/[- ]+/g, '');
12
+ var sum = 0;
13
+ var digit;
14
+ var tmpNum;
15
+ var shouldDouble;
16
+ for (var i = sanitized.length - 1; i >= 0; i--) {
17
+ digit = sanitized.substring(i, i + 1);
18
+ tmpNum = parseInt(digit, 10);
19
+ if (shouldDouble) {
20
+ tmpNum *= 2;
21
+ if (tmpNum >= 10) {
22
+ sum += tmpNum % 10 + 1;
23
+ } else {
24
+ sum += tmpNum;
25
+ }
26
+ } else {
27
+ sum += tmpNum;
28
+ }
29
+ shouldDouble = !shouldDouble;
30
+ }
31
+ return !!(sum % 10 === 0 ? sanitized : false);
32
+ }
33
+ module.exports = exports.default;
34
+ module.exports.default = exports.default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMACAddress;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var macAddress48 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
10
+ var macAddress48NoSeparators = /^([0-9a-fA-F]){12}$/;
11
+ var macAddress48WithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
12
+ var macAddress64 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){6}([0-9a-fA-F]{2})$/;
13
+ var macAddress64NoSeparators = /^([0-9a-fA-F]){16}$/;
14
+ var macAddress64WithDots = /^([0-9a-fA-F]{4}\.){3}([0-9a-fA-F]{4})$/;
15
+ function isMACAddress(str, options) {
16
+ (0, _assertString.default)(str);
17
+ if (options !== null && options !== void 0 && options.eui) {
18
+ options.eui = String(options.eui);
19
+ }
20
+ /**
21
+ * @deprecated `no_colons` TODO: remove it in the next major
22
+ */
23
+ if (options !== null && options !== void 0 && options.no_colons || options !== null && options !== void 0 && options.no_separators) {
24
+ if (options.eui === '48') {
25
+ return macAddress48NoSeparators.test(str);
26
+ }
27
+ if (options.eui === '64') {
28
+ return macAddress64NoSeparators.test(str);
29
+ }
30
+ return macAddress48NoSeparators.test(str) || macAddress64NoSeparators.test(str);
31
+ }
32
+ if ((options === null || options === void 0 ? void 0 : options.eui) === '48') {
33
+ return macAddress48.test(str) || macAddress48WithDots.test(str);
34
+ }
35
+ if ((options === null || options === void 0 ? void 0 : options.eui) === '64') {
36
+ return macAddress64.test(str) || macAddress64WithDots.test(str);
37
+ }
38
+ return isMACAddress(str, {
39
+ eui: '48'
40
+ }) || isMACAddress(str, {
41
+ eui: '64'
42
+ });
43
+ }
44
+ module.exports = exports.default;
45
+ module.exports.default = exports.default;
package/lib/isMD5.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMD5;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var md5 = /^[a-f0-9]{32}$/;
10
+ function isMD5(str) {
11
+ (0, _assertString.default)(str);
12
+ return md5.test(str);
13
+ }
14
+ module.exports = exports.default;
15
+ module.exports.default = exports.default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMagnetURI;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var magnetURIComponent = /(?:^magnet:\?|[^?&]&)xt(?:\.1)?=urn:(?:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})(?:$|&)/i;
10
+ function isMagnetURI(url) {
11
+ (0, _assertString.default)(url);
12
+ if (url.indexOf('magnet:?') !== 0) {
13
+ return false;
14
+ }
15
+ return magnetURIComponent.test(url);
16
+ }
17
+ module.exports = exports.default;
18
+ module.exports.default = exports.default;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMailtoURI;
7
+ var _trim = _interopRequireDefault(require("./trim"));
8
+ var _isEmail = _interopRequireDefault(require("./isEmail"));
9
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
12
+ 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."); }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
15
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
16
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
17
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
+ function parseMailtoQueryString(queryString) {
19
+ var allowedParams = new Set(['subject', 'body', 'cc', 'bcc']),
20
+ query = {
21
+ cc: '',
22
+ bcc: ''
23
+ };
24
+ var isParseFailed = false;
25
+ var queryParams = queryString.split('&');
26
+ if (queryParams.length > 4) {
27
+ return false;
28
+ }
29
+ var _iterator = _createForOfIteratorHelper(queryParams),
30
+ _step;
31
+ try {
32
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
33
+ var q = _step.value;
34
+ var _q$split = q.split('='),
35
+ _q$split2 = _slicedToArray(_q$split, 2),
36
+ key = _q$split2[0],
37
+ value = _q$split2[1];
38
+
39
+ // checked for invalid and duplicated query params
40
+ if (key && !allowedParams.has(key)) {
41
+ isParseFailed = true;
42
+ break;
43
+ }
44
+ if (value && (key === 'cc' || key === 'bcc')) {
45
+ query[key] = value;
46
+ }
47
+ if (key) {
48
+ allowedParams.delete(key);
49
+ }
50
+ }
51
+ } catch (err) {
52
+ _iterator.e(err);
53
+ } finally {
54
+ _iterator.f();
55
+ }
56
+ return isParseFailed ? false : query;
57
+ }
58
+ function isMailtoURI(url, options) {
59
+ (0, _assertString.default)(url);
60
+ if (url.indexOf('mailto:') !== 0) {
61
+ return false;
62
+ }
63
+ var _url$replace$split = url.replace('mailto:', '').split('?'),
64
+ _url$replace$split2 = _slicedToArray(_url$replace$split, 2),
65
+ to = _url$replace$split2[0],
66
+ _url$replace$split2$ = _url$replace$split2[1],
67
+ queryString = _url$replace$split2$ === void 0 ? '' : _url$replace$split2$;
68
+ if (!to && !queryString) {
69
+ return true;
70
+ }
71
+ var query = parseMailtoQueryString(queryString);
72
+ if (!query) {
73
+ return false;
74
+ }
75
+ return "".concat(to, ",").concat(query.cc, ",").concat(query.bcc).split(',').every(function (email) {
76
+ email = (0, _trim.default)(email, ' ');
77
+ if (email) {
78
+ return (0, _isEmail.default)(email, options);
79
+ }
80
+ return true;
81
+ });
82
+ }
83
+ module.exports = exports.default;
84
+ module.exports.default = exports.default;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMimeType;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ /*
10
+ Checks if the provided string matches to a correct Media type format (MIME type)
11
+
12
+ This function only checks is the string format follows the
13
+ established rules by the according RFC specifications.
14
+ This function supports 'charset' in textual media types
15
+ (https://tools.ietf.org/html/rfc6657).
16
+
17
+ This function does not check against all the media types listed
18
+ by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
19
+ because of lightness purposes : it would require to include
20
+ all these MIME types in this library, which would weigh it
21
+ significantly. This kind of effort maybe is not worth for the use that
22
+ this function has in this entire library.
23
+
24
+ More information in the RFC specifications :
25
+ - https://tools.ietf.org/html/rfc2045
26
+ - https://tools.ietf.org/html/rfc2046
27
+ - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
28
+ - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
29
+ */
30
+
31
+ // Match simple MIME types
32
+ // NB :
33
+ // Subtype length must not exceed 100 characters.
34
+ // This rule does not comply to the RFC specs (what is the max length ?).
35
+ var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+_]{1,100}$/i; // eslint-disable-line max-len
36
+
37
+ // Handle "charset" in "text/*"
38
+ var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
39
+
40
+ // Handle "boundary" in "multipart/*"
41
+ var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
42
+
43
+ function isMimeType(str) {
44
+ (0, _assertString.default)(str);
45
+ return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
46
+ }
47
+ module.exports = exports.default;
48
+ module.exports.default = exports.default;