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/isTime.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isTime;
7
+ var _merge = _interopRequireDefault(require("./util/merge"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var default_time_options = {
10
+ hourFormat: 'hour24',
11
+ mode: 'default'
12
+ };
13
+ var formats = {
14
+ hour24: {
15
+ default: /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/,
16
+ withSeconds: /^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/
17
+ },
18
+ hour12: {
19
+ default: /^(0?[1-9]|1[0-2]):([0-5][0-9]) (A|P)M$/,
20
+ withSeconds: /^(0?[1-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]) (A|P)M$/
21
+ }
22
+ };
23
+ function isTime(input, options) {
24
+ options = (0, _merge.default)(options, default_time_options);
25
+ if (typeof input !== 'string') return false;
26
+ return formats[options.hourFormat][options.mode].test(input);
27
+ }
28
+ module.exports = exports.default;
29
+ module.exports.default = exports.default;
package/lib/isURL.js ADDED
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isURL;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isFQDN = _interopRequireDefault(require("./isFQDN"));
9
+ var _isIP = _interopRequireDefault(require("./isIP"));
10
+ var _merge = _interopRequireDefault(require("./util/merge"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ 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."); }
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
+ 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; } }
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+ /*
19
+ options for isURL method
20
+
21
+ require_protocol - if set as true isURL will return false if protocol is not present in the URL
22
+ require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
23
+ protocols - valid protocols can be modified with this option
24
+ require_host - if set as false isURL will not check if host is present in the URL
25
+ require_port - if set as true isURL will check if port is present in the URL
26
+ allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
27
+ validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
28
+
29
+ */
30
+
31
+ var default_url_options = {
32
+ protocols: ['http', 'https', 'ftp'],
33
+ require_tld: true,
34
+ require_protocol: false,
35
+ require_host: true,
36
+ require_port: false,
37
+ require_valid_protocol: true,
38
+ allow_underscores: false,
39
+ allow_trailing_dot: false,
40
+ allow_protocol_relative_urls: false,
41
+ allow_fragments: true,
42
+ allow_query_components: true,
43
+ validate_length: true
44
+ };
45
+ var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
46
+ function isRegExp(obj) {
47
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
48
+ }
49
+ function checkHost(host, matches) {
50
+ for (var i = 0; i < matches.length; i++) {
51
+ var match = matches[i];
52
+ if (host === match || isRegExp(match) && match.test(host)) {
53
+ return true;
54
+ }
55
+ }
56
+ return false;
57
+ }
58
+ function isURL(url, options) {
59
+ (0, _assertString.default)(url);
60
+ if (!url || /[\s<>]/.test(url)) {
61
+ return false;
62
+ }
63
+ if (url.indexOf('mailto:') === 0) {
64
+ return false;
65
+ }
66
+ options = (0, _merge.default)(options, default_url_options);
67
+ if (options.validate_length && url.length >= 2083) {
68
+ return false;
69
+ }
70
+ if (!options.allow_fragments && url.includes('#')) {
71
+ return false;
72
+ }
73
+ if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) {
74
+ return false;
75
+ }
76
+ var protocol, auth, host, hostname, port, port_str, split, ipv6;
77
+ split = url.split('#');
78
+ url = split.shift();
79
+ split = url.split('?');
80
+ url = split.shift();
81
+ split = url.split('://');
82
+ if (split.length > 1) {
83
+ protocol = split.shift().toLowerCase();
84
+ if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
85
+ return false;
86
+ }
87
+ } else if (options.require_protocol) {
88
+ return false;
89
+ } else if (url.slice(0, 2) === '//') {
90
+ if (!options.allow_protocol_relative_urls) {
91
+ return false;
92
+ }
93
+ split[0] = url.slice(2);
94
+ }
95
+ url = split.join('://');
96
+ if (url === '') {
97
+ return false;
98
+ }
99
+ split = url.split('/');
100
+ url = split.shift();
101
+ if (url === '' && !options.require_host) {
102
+ return true;
103
+ }
104
+ split = url.split('@');
105
+ if (split.length > 1) {
106
+ if (options.disallow_auth) {
107
+ return false;
108
+ }
109
+ if (split[0] === '') {
110
+ return false;
111
+ }
112
+ auth = split.shift();
113
+ if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
114
+ return false;
115
+ }
116
+ var _auth$split = auth.split(':'),
117
+ _auth$split2 = _slicedToArray(_auth$split, 2),
118
+ user = _auth$split2[0],
119
+ password = _auth$split2[1];
120
+ if (user === '' && password === '') {
121
+ return false;
122
+ }
123
+ }
124
+ hostname = split.join('@');
125
+ port_str = null;
126
+ ipv6 = null;
127
+ var ipv6_match = hostname.match(wrapped_ipv6);
128
+ if (ipv6_match) {
129
+ host = '';
130
+ ipv6 = ipv6_match[1];
131
+ port_str = ipv6_match[2] || null;
132
+ } else {
133
+ split = hostname.split(':');
134
+ host = split.shift();
135
+ if (split.length) {
136
+ port_str = split.join(':');
137
+ }
138
+ }
139
+ if (port_str !== null && port_str.length > 0) {
140
+ port = parseInt(port_str, 10);
141
+ if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
142
+ return false;
143
+ }
144
+ } else if (options.require_port) {
145
+ return false;
146
+ }
147
+ if (options.host_whitelist) {
148
+ return checkHost(host, options.host_whitelist);
149
+ }
150
+ if (host === '' && !options.require_host) {
151
+ return true;
152
+ }
153
+ if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
154
+ return false;
155
+ }
156
+ host = host || ipv6;
157
+ if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
158
+ return false;
159
+ }
160
+ return true;
161
+ }
162
+ module.exports = exports.default;
163
+ module.exports.default = exports.default;
package/lib/isUUID.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isUUID;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var uuid = {
10
+ 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
11
+ 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
12
+ 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
13
+ 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
14
+ 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
15
+ 7: /^[0-9A-F]{8}-[0-9A-F]{4}-7[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
16
+ all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
17
+ };
18
+ function isUUID(str, version) {
19
+ (0, _assertString.default)(str);
20
+ var pattern = uuid[![undefined, null].includes(version) ? version : 'all'];
21
+ return !!pattern && pattern.test(str);
22
+ }
23
+ module.exports = exports.default;
24
+ 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 = isUppercase;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function isUppercase(str) {
10
+ (0, _assertString.default)(str);
11
+ return str === str.toUpperCase();
12
+ }
13
+ module.exports = exports.default;
14
+ module.exports.default = exports.default;
package/lib/isVAT.js ADDED
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = isVAT;
8
+ exports.vatMatchers = void 0;
9
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
10
+ var algorithms = _interopRequireWildcard(require("./util/algorithms"));
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ var AU = function AU(str) {
15
+ var match = str.match(/^(AU)?(\d{11})$/);
16
+ if (!match) {
17
+ return false;
18
+ }
19
+ // @see {@link https://abr.business.gov.au/Help/AbnFormat}
20
+ var weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
21
+ str = str.replace(/^AU/, '');
22
+ var ABN = (parseInt(str.slice(0, 1), 10) - 1).toString() + str.slice(1);
23
+ var total = 0;
24
+ for (var i = 0; i < 11; i++) {
25
+ total += weights[i] * ABN.charAt(i);
26
+ }
27
+ return total !== 0 && total % 89 === 0;
28
+ };
29
+ var CH = function CH(str) {
30
+ // @see {@link https://www.ech.ch/de/ech/ech-0097/5.2.0}
31
+ var hasValidCheckNumber = function hasValidCheckNumber(digits) {
32
+ var lastDigit = digits.pop(); // used as check number
33
+ var weights = [5, 4, 3, 2, 7, 6, 5, 4];
34
+ var calculatedCheckNumber = (11 - digits.reduce(function (acc, el, idx) {
35
+ return acc + el * weights[idx];
36
+ }, 0) % 11) % 11;
37
+ return lastDigit === calculatedCheckNumber;
38
+ };
39
+
40
+ // @see {@link https://www.estv.admin.ch/estv/de/home/mehrwertsteuer/uid/mwst-uid-nummer.html}
41
+ return /^(CHE[- ]?)?(\d{9}|(\d{3}\.\d{3}\.\d{3})|(\d{3} \d{3} \d{3})) ?(TVA|MWST|IVA)?$/.test(str) && hasValidCheckNumber(str.match(/\d/g).map(function (el) {
42
+ return +el;
43
+ }));
44
+ };
45
+ var PT = function PT(str) {
46
+ var match = str.match(/^(PT)?(\d{9})$/);
47
+ if (!match) {
48
+ return false;
49
+ }
50
+ var tin = match[2];
51
+ var checksum = 11 - algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
52
+ return parseInt(a, 10);
53
+ }), 9) % 11;
54
+ if (checksum > 9) {
55
+ return parseInt(tin[8], 10) === 0;
56
+ }
57
+ return checksum === parseInt(tin[8], 10);
58
+ };
59
+ var vatMatchers = exports.vatMatchers = {
60
+ /**
61
+ * European Union VAT identification numbers
62
+ */
63
+ AT: function AT(str) {
64
+ return /^(AT)?U\d{8}$/.test(str);
65
+ },
66
+ BE: function BE(str) {
67
+ return /^(BE)?\d{10}$/.test(str);
68
+ },
69
+ BG: function BG(str) {
70
+ return /^(BG)?\d{9,10}$/.test(str);
71
+ },
72
+ HR: function HR(str) {
73
+ return /^(HR)?\d{11}$/.test(str);
74
+ },
75
+ CY: function CY(str) {
76
+ return /^(CY)?\w{9}$/.test(str);
77
+ },
78
+ CZ: function CZ(str) {
79
+ return /^(CZ)?\d{8,10}$/.test(str);
80
+ },
81
+ DK: function DK(str) {
82
+ return /^(DK)?\d{8}$/.test(str);
83
+ },
84
+ EE: function EE(str) {
85
+ return /^(EE)?\d{9}$/.test(str);
86
+ },
87
+ FI: function FI(str) {
88
+ return /^(FI)?\d{8}$/.test(str);
89
+ },
90
+ FR: function FR(str) {
91
+ return /^(FR)?\w{2}\d{9}$/.test(str);
92
+ },
93
+ DE: function DE(str) {
94
+ return /^(DE)?\d{9}$/.test(str);
95
+ },
96
+ EL: function EL(str) {
97
+ return /^(EL)?\d{9}$/.test(str);
98
+ },
99
+ HU: function HU(str) {
100
+ return /^(HU)?\d{8}$/.test(str);
101
+ },
102
+ IE: function IE(str) {
103
+ return /^(IE)?\d{7}\w{1}(W)?$/.test(str);
104
+ },
105
+ IT: function IT(str) {
106
+ return /^(IT)?\d{11}$/.test(str);
107
+ },
108
+ LV: function LV(str) {
109
+ return /^(LV)?\d{11}$/.test(str);
110
+ },
111
+ LT: function LT(str) {
112
+ return /^(LT)?\d{9,12}$/.test(str);
113
+ },
114
+ LU: function LU(str) {
115
+ return /^(LU)?\d{8}$/.test(str);
116
+ },
117
+ MT: function MT(str) {
118
+ return /^(MT)?\d{8}$/.test(str);
119
+ },
120
+ NL: function NL(str) {
121
+ return /^(NL)?\d{9}B\d{2}$/.test(str);
122
+ },
123
+ PL: function PL(str) {
124
+ return /^(PL)?(\d{10}|(\d{3}-\d{3}-\d{2}-\d{2})|(\d{3}-\d{2}-\d{2}-\d{3}))$/.test(str);
125
+ },
126
+ PT: PT,
127
+ RO: function RO(str) {
128
+ return /^(RO)?\d{2,10}$/.test(str);
129
+ },
130
+ SK: function SK(str) {
131
+ return /^(SK)?\d{10}$/.test(str);
132
+ },
133
+ SI: function SI(str) {
134
+ return /^(SI)?\d{8}$/.test(str);
135
+ },
136
+ ES: function ES(str) {
137
+ return /^(ES)?\w\d{7}[A-Z]$/.test(str);
138
+ },
139
+ SE: function SE(str) {
140
+ return /^(SE)?\d{12}$/.test(str);
141
+ },
142
+ /**
143
+ * VAT numbers of non-EU countries
144
+ */
145
+ AL: function AL(str) {
146
+ return /^(AL)?\w{9}[A-Z]$/.test(str);
147
+ },
148
+ MK: function MK(str) {
149
+ return /^(MK)?\d{13}$/.test(str);
150
+ },
151
+ AU: AU,
152
+ BY: function BY(str) {
153
+ return /^(УНП )?\d{9}$/.test(str);
154
+ },
155
+ CA: function CA(str) {
156
+ return /^(CA)?\d{9}$/.test(str);
157
+ },
158
+ IS: function IS(str) {
159
+ return /^(IS)?\d{5,6}$/.test(str);
160
+ },
161
+ IN: function IN(str) {
162
+ return /^(IN)?\d{15}$/.test(str);
163
+ },
164
+ ID: function ID(str) {
165
+ return /^(ID)?(\d{15}|(\d{2}.\d{3}.\d{3}.\d{1}-\d{3}.\d{3}))$/.test(str);
166
+ },
167
+ IL: function IL(str) {
168
+ return /^(IL)?\d{9}$/.test(str);
169
+ },
170
+ KZ: function KZ(str) {
171
+ return /^(KZ)?\d{12}$/.test(str);
172
+ },
173
+ NZ: function NZ(str) {
174
+ return /^(NZ)?\d{9}$/.test(str);
175
+ },
176
+ NG: function NG(str) {
177
+ return /^(NG)?(\d{12}|(\d{8}-\d{4}))$/.test(str);
178
+ },
179
+ NO: function NO(str) {
180
+ return /^(NO)?\d{9}MVA$/.test(str);
181
+ },
182
+ PH: function PH(str) {
183
+ return /^(PH)?(\d{12}|\d{3} \d{3} \d{3} \d{3})$/.test(str);
184
+ },
185
+ RU: function RU(str) {
186
+ return /^(RU)?(\d{10}|\d{12})$/.test(str);
187
+ },
188
+ SM: function SM(str) {
189
+ return /^(SM)?\d{5}$/.test(str);
190
+ },
191
+ SA: function SA(str) {
192
+ return /^(SA)?\d{15}$/.test(str);
193
+ },
194
+ RS: function RS(str) {
195
+ return /^(RS)?\d{9}$/.test(str);
196
+ },
197
+ CH: CH,
198
+ TR: function TR(str) {
199
+ return /^(TR)?\d{10}$/.test(str);
200
+ },
201
+ UA: function UA(str) {
202
+ return /^(UA)?\d{12}$/.test(str);
203
+ },
204
+ GB: function GB(str) {
205
+ return /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/.test(str);
206
+ },
207
+ UZ: function UZ(str) {
208
+ return /^(UZ)?\d{9}$/.test(str);
209
+ },
210
+ /**
211
+ * VAT numbers of Latin American countries
212
+ */
213
+ AR: function AR(str) {
214
+ return /^(AR)?\d{11}$/.test(str);
215
+ },
216
+ BO: function BO(str) {
217
+ return /^(BO)?\d{7}$/.test(str);
218
+ },
219
+ BR: function BR(str) {
220
+ return /^(BR)?((\d{2}.\d{3}.\d{3}\/\d{4}-\d{2})|(\d{3}.\d{3}.\d{3}-\d{2}))$/.test(str);
221
+ },
222
+ CL: function CL(str) {
223
+ return /^(CL)?\d{8}-\d{1}$/.test(str);
224
+ },
225
+ CO: function CO(str) {
226
+ return /^(CO)?\d{10}$/.test(str);
227
+ },
228
+ CR: function CR(str) {
229
+ return /^(CR)?\d{9,12}$/.test(str);
230
+ },
231
+ EC: function EC(str) {
232
+ return /^(EC)?\d{13}$/.test(str);
233
+ },
234
+ SV: function SV(str) {
235
+ return /^(SV)?\d{4}-\d{6}-\d{3}-\d{1}$/.test(str);
236
+ },
237
+ GT: function GT(str) {
238
+ return /^(GT)?\d{7}-\d{1}$/.test(str);
239
+ },
240
+ HN: function HN(str) {
241
+ return /^(HN)?$/.test(str);
242
+ },
243
+ MX: function MX(str) {
244
+ return /^(MX)?\w{3,4}\d{6}\w{3}$/.test(str);
245
+ },
246
+ NI: function NI(str) {
247
+ return /^(NI)?\d{3}-\d{6}-\d{4}\w{1}$/.test(str);
248
+ },
249
+ PA: function PA(str) {
250
+ return /^(PA)?$/.test(str);
251
+ },
252
+ PY: function PY(str) {
253
+ return /^(PY)?\d{6,8}-\d{1}$/.test(str);
254
+ },
255
+ PE: function PE(str) {
256
+ return /^(PE)?\d{11}$/.test(str);
257
+ },
258
+ DO: function DO(str) {
259
+ return /^(DO)?(\d{11}|(\d{3}-\d{7}-\d{1})|[1,4,5]{1}\d{8}|([1,4,5]{1})-\d{2}-\d{5}-\d{1})$/.test(str);
260
+ },
261
+ UY: function UY(str) {
262
+ return /^(UY)?\d{12}$/.test(str);
263
+ },
264
+ VE: function VE(str) {
265
+ return /^(VE)?[J,G,V,E]{1}-(\d{9}|(\d{8}-\d{1}))$/.test(str);
266
+ }
267
+ };
268
+ function isVAT(str, countryCode) {
269
+ (0, _assertString.default)(str);
270
+ (0, _assertString.default)(countryCode);
271
+ if (countryCode in vatMatchers) {
272
+ return vatMatchers[countryCode](str);
273
+ }
274
+ throw new Error("Invalid country code: '".concat(countryCode, "'"));
275
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isVariableWidth;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isFullWidth = require("./isFullWidth");
9
+ var _isHalfWidth = require("./isHalfWidth");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function isVariableWidth(str) {
12
+ (0, _assertString.default)(str);
13
+ return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
14
+ }
15
+ module.exports = exports.default;
16
+ module.exports.default = exports.default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isWhitelisted;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function isWhitelisted(str, chars) {
10
+ (0, _assertString.default)(str);
11
+ for (var i = str.length - 1; i >= 0; i--) {
12
+ if (chars.indexOf(str[i]) === -1) {
13
+ return false;
14
+ }
15
+ }
16
+ return true;
17
+ }
18
+ module.exports = exports.default;
19
+ module.exports.default = exports.default;
package/lib/ltrim.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ltrim;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function ltrim(str, chars) {
10
+ (0, _assertString.default)(str);
11
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
12
+ var pattern = chars ? new RegExp("^[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+"), 'g') : /^\s+/g;
13
+ return str.replace(pattern, '');
14
+ }
15
+ module.exports = exports.default;
16
+ module.exports.default = exports.default;
package/lib/matches.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = matches;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function matches(str, pattern, modifiers) {
10
+ (0, _assertString.default)(str);
11
+ if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
12
+ pattern = new RegExp(pattern, modifiers);
13
+ }
14
+ return !!str.match(pattern);
15
+ }
16
+ module.exports = exports.default;
17
+ module.exports.default = exports.default;