valgen 5.3.0 → 5.3.2

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 (172) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/core/context.js +2 -3
  3. package/cjs/core/validator.js +4 -4
  4. package/cjs/index.js +5 -5
  5. package/cjs/rules/format-rules/is-alpha.js +52 -0
  6. package/cjs/rules/format-rules/is-ascii.js +40 -0
  7. package/cjs/rules/format-rules/is-base64.js +40 -0
  8. package/cjs/rules/format-rules/is-btc-address.js +40 -0
  9. package/cjs/rules/format-rules/is-credit-card.js +40 -0
  10. package/cjs/rules/format-rules/is-decimal.js +41 -0
  11. package/cjs/rules/format-rules/is-ean.js +40 -0
  12. package/cjs/rules/format-rules/is-email.js +97 -0
  13. package/cjs/rules/format-rules/is-eth-address.js +40 -0
  14. package/cjs/rules/format-rules/is-fqdn.js +44 -0
  15. package/cjs/rules/format-rules/is-hash.js +40 -0
  16. package/cjs/rules/format-rules/is-hex-color.js +40 -0
  17. package/cjs/rules/format-rules/is-hex.js +40 -0
  18. package/cjs/rules/format-rules/is-iban.js +52 -0
  19. package/cjs/rules/format-rules/is-ip.js +52 -0
  20. package/cjs/rules/format-rules/is-issn.js +44 -0
  21. package/cjs/rules/format-rules/is-jwt.js +40 -0
  22. package/cjs/rules/format-rules/is-lowercase.js +52 -0
  23. package/cjs/rules/format-rules/is-mac-address.js +45 -0
  24. package/cjs/rules/format-rules/is-mobile-phone.js +43 -0
  25. package/cjs/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
  26. package/cjs/rules/format-rules/is-passport-number.js +40 -0
  27. package/cjs/rules/format-rules/is-port.js +40 -0
  28. package/cjs/rules/format-rules/is-url.js +40 -0
  29. package/cjs/rules/format-rules/is-uuid.js +40 -0
  30. package/cjs/rules/format-rules/is-vat-number.js +40 -0
  31. package/cjs/rules/{is-regexp.js → format-rules/matches.js} +8 -5
  32. package/cjs/rules/index.js +49 -22
  33. package/cjs/rules/logical-rules/is-defined.js +30 -0
  34. package/cjs/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
  35. package/cjs/rules/{range.js → logical-rules/range.js} +63 -38
  36. package/cjs/rules/{is-any.js → type-rules/is-any.js} +1 -1
  37. package/cjs/rules/{is-array.js → type-rules/is-array.js} +2 -4
  38. package/cjs/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
  39. package/cjs/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
  40. package/cjs/rules/{is-date.js → type-rules/is-date.js} +5 -5
  41. package/cjs/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
  42. package/cjs/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
  43. package/cjs/rules/{is-null.js → type-rules/is-null.js} +2 -28
  44. package/cjs/rules/{is-number.js → type-rules/is-number.js} +2 -3
  45. package/cjs/rules/{is-object.js → type-rules/is-object.js} +3 -4
  46. package/cjs/rules/{is-record.js → type-rules/is-record.js} +1 -1
  47. package/cjs/rules/{is-string.js → type-rules/is-string.js} +1 -1
  48. package/cjs/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
  49. package/cjs/rules/utility-rules/exists.js +16 -0
  50. package/cjs/rules/utility-rules/get-length.js +24 -0
  51. package/cjs/rules/utility-rules/optional.js +16 -0
  52. package/cjs/rules/{pipe.js → utility-rules/pipe.js} +1 -1
  53. package/cjs/rules/utility-rules/required.js +18 -0
  54. package/cjs/rules/{union.js → utility-rules/union.js} +2 -2
  55. package/esm/core/context.js +2 -3
  56. package/esm/core/validator.js +4 -4
  57. package/esm/index.js +3 -3
  58. package/esm/rules/format-rules/is-alpha.js +24 -0
  59. package/esm/rules/format-rules/is-ascii.js +13 -0
  60. package/esm/rules/format-rules/is-base64.js +13 -0
  61. package/esm/rules/format-rules/is-btc-address.js +13 -0
  62. package/esm/rules/format-rules/is-credit-card.js +13 -0
  63. package/esm/rules/format-rules/is-decimal.js +14 -0
  64. package/esm/rules/format-rules/is-ean.js +13 -0
  65. package/esm/rules/format-rules/is-email.js +70 -0
  66. package/esm/rules/format-rules/is-eth-address.js +13 -0
  67. package/esm/rules/format-rules/is-fqdn.js +17 -0
  68. package/esm/rules/format-rules/is-hash.js +13 -0
  69. package/esm/rules/format-rules/is-hex-color.js +13 -0
  70. package/esm/rules/format-rules/is-hex.js +13 -0
  71. package/esm/rules/format-rules/is-iban.js +24 -0
  72. package/esm/rules/format-rules/is-ip.js +24 -0
  73. package/esm/rules/format-rules/is-issn.js +17 -0
  74. package/esm/rules/format-rules/is-jwt.js +13 -0
  75. package/esm/rules/format-rules/is-lowercase.js +24 -0
  76. package/esm/rules/format-rules/is-mac-address.js +18 -0
  77. package/esm/rules/format-rules/is-mobile-phone.js +16 -0
  78. package/esm/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
  79. package/esm/rules/format-rules/is-passport-number.js +13 -0
  80. package/esm/rules/format-rules/is-port.js +13 -0
  81. package/esm/rules/format-rules/is-url.js +13 -0
  82. package/esm/rules/format-rules/is-uuid.js +13 -0
  83. package/esm/rules/format-rules/is-vat-number.js +13 -0
  84. package/esm/rules/{is-regexp.js → format-rules/matches.js} +6 -3
  85. package/esm/rules/index.js +49 -22
  86. package/esm/rules/logical-rules/is-defined.js +25 -0
  87. package/esm/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
  88. package/esm/rules/{range.js → logical-rules/range.js} +59 -36
  89. package/esm/rules/{is-any.js → type-rules/is-any.js} +1 -1
  90. package/esm/rules/{is-array.js → type-rules/is-array.js} +2 -4
  91. package/esm/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
  92. package/esm/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
  93. package/esm/rules/{is-date.js → type-rules/is-date.js} +5 -5
  94. package/esm/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
  95. package/esm/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
  96. package/esm/rules/{is-null.js → type-rules/is-null.js} +1 -25
  97. package/esm/rules/{is-number.js → type-rules/is-number.js} +2 -3
  98. package/esm/rules/{is-object.js → type-rules/is-object.js} +3 -4
  99. package/esm/rules/{is-record.js → type-rules/is-record.js} +1 -1
  100. package/esm/rules/{is-string.js → type-rules/is-string.js} +1 -1
  101. package/esm/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
  102. package/esm/rules/utility-rules/exists.js +12 -0
  103. package/esm/rules/utility-rules/get-length.js +20 -0
  104. package/esm/rules/utility-rules/optional.js +12 -0
  105. package/esm/rules/{pipe.js → utility-rules/pipe.js} +1 -1
  106. package/esm/rules/utility-rules/required.js +14 -0
  107. package/esm/rules/{union.js → utility-rules/union.js} +2 -2
  108. package/package.json +3 -3
  109. package/typings/index.d.ts +4 -4
  110. package/typings/rules/format-rules/is-alpha.d.ts +11 -0
  111. package/typings/rules/format-rules/is-ascii.d.ts +6 -0
  112. package/typings/rules/format-rules/is-base64.d.ts +9 -0
  113. package/typings/rules/format-rules/is-btc-address.d.ts +6 -0
  114. package/typings/rules/format-rules/is-credit-card.d.ts +9 -0
  115. package/typings/rules/format-rules/is-decimal.d.ts +7 -0
  116. package/typings/rules/format-rules/is-ean.d.ts +6 -0
  117. package/typings/rules/format-rules/is-email.d.ts +62 -0
  118. package/typings/rules/format-rules/is-eth-address.d.ts +6 -0
  119. package/typings/rules/format-rules/is-fqdn.d.ts +13 -0
  120. package/typings/rules/format-rules/is-hash.d.ts +8 -0
  121. package/typings/rules/format-rules/is-hex-color.d.ts +6 -0
  122. package/typings/rules/format-rules/is-hex.d.ts +6 -0
  123. package/typings/rules/format-rules/is-iban.d.ts +11 -0
  124. package/typings/rules/format-rules/is-ip.d.ts +11 -0
  125. package/typings/rules/format-rules/is-issn.d.ts +14 -0
  126. package/typings/rules/format-rules/is-jwt.d.ts +6 -0
  127. package/typings/rules/format-rules/is-lowercase.d.ts +11 -0
  128. package/typings/rules/format-rules/is-mac-address.d.ts +21 -0
  129. package/typings/rules/format-rules/is-mobile-phone.d.ts +20 -0
  130. package/typings/rules/{is-object-id.d.ts → format-rules/is-object-id.d.ts} +2 -2
  131. package/typings/rules/format-rules/is-passport-number.d.ts +6 -0
  132. package/typings/rules/format-rules/is-port.d.ts +6 -0
  133. package/typings/rules/format-rules/is-url.d.ts +9 -0
  134. package/typings/rules/format-rules/is-uuid.d.ts +6 -0
  135. package/typings/rules/format-rules/is-vat-number.d.ts +6 -0
  136. package/typings/rules/format-rules/matches.d.ts +9 -0
  137. package/typings/rules/index.d.ts +49 -22
  138. package/typings/rules/logical-rules/is-defined.d.ts +11 -0
  139. package/typings/rules/{is-empty.d.ts → logical-rules/is-empty.d.ts} +3 -3
  140. package/typings/rules/{range.d.ts → logical-rules/range.d.ts} +14 -4
  141. package/typings/rules/type-rules/is-any.d.ts +5 -0
  142. package/typings/rules/{is-array.d.ts → type-rules/is-array.d.ts} +2 -2
  143. package/typings/rules/{is-bigint.d.ts → type-rules/is-bigint.d.ts} +2 -2
  144. package/typings/rules/{is-boolean.d.ts → type-rules/is-boolean.d.ts} +2 -2
  145. package/typings/rules/{is-date.d.ts → type-rules/is-date.d.ts} +3 -3
  146. package/typings/rules/{is-enum.d.ts → type-rules/is-enum.d.ts} +1 -1
  147. package/typings/rules/{is-integer.d.ts → type-rules/is-integer.d.ts} +2 -2
  148. package/typings/rules/type-rules/is-null.d.ts +11 -0
  149. package/typings/rules/{is-number.d.ts → type-rules/is-number.d.ts} +2 -2
  150. package/typings/rules/{is-object.d.ts → type-rules/is-object.d.ts} +1 -1
  151. package/typings/rules/{is-record.d.ts → type-rules/is-record.d.ts} +2 -2
  152. package/typings/rules/{is-string.d.ts → type-rules/is-string.d.ts} +5 -5
  153. package/typings/rules/{is-tuple.d.ts → type-rules/is-tuple.d.ts} +2 -8
  154. package/typings/rules/utility-rules/exists.d.ts +6 -0
  155. package/typings/rules/utility-rules/get-length.d.ts +11 -0
  156. package/typings/rules/utility-rules/optional.d.ts +7 -0
  157. package/typings/rules/{pipe.d.ts → utility-rules/pipe.d.ts} +1 -1
  158. package/typings/rules/utility-rules/required.d.ts +7 -0
  159. package/typings/rules/utility-rules/union.d.ts +5 -0
  160. package/cjs/rules/length.js +0 -41
  161. package/cjs/rules/optional.js +0 -44
  162. package/cjs/rules/string-formats.js +0 -377
  163. package/esm/rules/length.js +0 -35
  164. package/esm/rules/optional.js +0 -38
  165. package/esm/rules/string-formats.js +0 -322
  166. package/typings/rules/is-any.d.ts +0 -5
  167. package/typings/rules/is-null.d.ts +0 -21
  168. package/typings/rules/is-regexp.d.ts +0 -9
  169. package/typings/rules/length.d.ts +0 -21
  170. package/typings/rules/optional.d.ts +0 -17
  171. package/typings/rules/string-formats.d.ts +0 -166
  172. package/typings/rules/union.d.ts +0 -5
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isHex = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Check if the string is a hexadecimal number.
31
+ * @validator isHex
32
+ */
33
+ function isHex(options) {
34
+ return (0, index_js_1.validator)('isHex', function (input, context, _this) {
35
+ if (typeof input === 'string' && validatorJS.isHexadecimal(input))
36
+ return input;
37
+ context.fail(_this, `{{label}} is not an hexadecimal string`, input);
38
+ }, options);
39
+ }
40
+ exports.isHex = isHex;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isSWIFT = exports.isIBAN = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an IBAN (International Bank Account Number)
31
+ * @validator isIBAN
32
+ */
33
+ function isIBAN(options) {
34
+ return (0, index_js_1.validator)('isIBAN', function (input, context, _this) {
35
+ if (typeof input === 'string' && validatorJS.isIBAN(input))
36
+ return input;
37
+ context.fail(_this, `{{label}} is not a valid IBAN (International Bank Account Number)`, input);
38
+ }, options);
39
+ }
40
+ exports.isIBAN = isIBAN;
41
+ /**
42
+ * Validates if value is a BIC (Bank Identification Code) or SWIFT code
43
+ * @validator isSWIFT
44
+ */
45
+ function isSWIFT(options) {
46
+ return (0, index_js_1.validator)('isSWIFT', function (input, context, _this) {
47
+ if (typeof input === 'string' && validatorJS.isBIC(input))
48
+ return input;
49
+ context.fail(_this, `{{label}}is not a valid a BIC (Bank Identification Code) or SWIFT code`, input);
50
+ }, options);
51
+ }
52
+ exports.isSWIFT = isSWIFT;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isIPRange = exports.isIP = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an IP
31
+ * @validator isIP
32
+ */
33
+ function isIP(version, options) {
34
+ return (0, index_js_1.validator)('isIP', function (input, context, _this) {
35
+ if (input != null && typeof input === 'string' && validatorJS.isIP(input, version))
36
+ return input;
37
+ context.fail(_this, `"{{value}}" is not a valid IP${version ? ' v' + version : ''}`, input);
38
+ }, options);
39
+ }
40
+ exports.isIP = isIP;
41
+ /**
42
+ * Validates if value is an IP
43
+ * @validator isIPRange
44
+ */
45
+ function isIPRange(version, options) {
46
+ return (0, index_js_1.validator)('isIPRange', function (input, context, _this) {
47
+ if (input != null && typeof input === 'string' && validatorJS.isIPRange(input, version))
48
+ return input;
49
+ context.fail(_this, `"{{value}}" is not a valid IP${version ? ' v' + version : ''} range`, input);
50
+ }, options);
51
+ }
52
+ exports.isIPRange = isIPRange;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isISSN = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an ISSN
31
+ * @validator isISSN
32
+ */
33
+ function isISSN(options) {
34
+ const opts = {
35
+ // eslint-disable-next-line camelcase
36
+ case_sensitive: options?.caseSensitive,
37
+ };
38
+ return (0, index_js_1.validator)('isISSN', function (input, context, _this) {
39
+ if (typeof input === 'string' && validatorJS.isISSN(input, opts))
40
+ return input;
41
+ context.fail(_this, `"{{value}}" is not a valid ISSN`, input);
42
+ }, options);
43
+ }
44
+ exports.isISSN = isISSN;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isJWT = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value a valid JWT token
31
+ * @validator isJWT
32
+ */
33
+ function isJWT(options) {
34
+ return (0, index_js_1.validator)('isJWT', function (input, context, _this) {
35
+ if (typeof input === 'string' && validatorJS.isJWT(input))
36
+ return input;
37
+ context.fail(_this, `Value is not a valid JWT token`, input);
38
+ }, options);
39
+ }
40
+ exports.isJWT = isJWT;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isUppercase = exports.isLowercase = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value a Lowercase string
31
+ * @validator isLowercase
32
+ */
33
+ function isLowercase(options) {
34
+ return (0, index_js_1.validator)('isLowercase', function (input, context, _this) {
35
+ if (typeof input === 'string' && validatorJS.isLowercase(input))
36
+ return input;
37
+ context.fail(_this, `"{{value}}" is not a lowercase string`, input);
38
+ }, options);
39
+ }
40
+ exports.isLowercase = isLowercase;
41
+ /**
42
+ * Validates if value a Uppercase string
43
+ * @validator isUppercase
44
+ */
45
+ function isUppercase(options) {
46
+ return (0, index_js_1.validator)('isUppercase', function (input, context, _this) {
47
+ if (typeof input === 'string' && validatorJS.isUppercase(input))
48
+ return input;
49
+ context.fail(_this, `"{{value}}" is not an uppercase string`, input);
50
+ }, options);
51
+ }
52
+ exports.isUppercase = isUppercase;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isMACAddress = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an MACAddress
31
+ * @validator isMACAddress
32
+ */
33
+ function isMACAddress(options) {
34
+ const opts = {
35
+ // eslint-disable-next-line camelcase
36
+ no_separators: options?.noSeparators,
37
+ eui: options?.eui,
38
+ };
39
+ return (0, index_js_1.validator)('isMACAddress', function (input, context, _this) {
40
+ if (input != null && typeof input === 'string' && validatorJS.isMACAddress(input, opts))
41
+ return input;
42
+ context.fail(_this, `{{label}} is not a valid MAC address`, input);
43
+ }, options);
44
+ }
45
+ exports.isMACAddress = isMACAddress;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isMobilePhone = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is a valid Email
31
+ * @validator isMobilePhone
32
+ */
33
+ function isMobilePhone(options) {
34
+ const opts = {
35
+ strictMode: options?.strictMode,
36
+ };
37
+ return (0, index_js_1.validator)('isMobilePhone', function (input, context, _this) {
38
+ if (typeof input === 'string' && validatorJS.isMobilePhone(input, options?.locale, opts))
39
+ return input;
40
+ context.fail(_this, `"{{value}}" is not a valid a Mobile Phone Number`, input);
41
+ }, options);
42
+ }
43
+ exports.isMobilePhone = isMobilePhone;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isObjectId = void 0;
7
7
  const validator_1 = __importDefault(require("validator"));
8
- const index_js_1 = require("../core/index.js");
8
+ const index_js_1 = require("../../core/index.js");
9
9
  /**
10
10
  * Validates if value is an "ObjectId".
11
11
  * @validator isObjectId
@@ -23,6 +23,6 @@ function isObjectId(options) {
23
23
  }
24
24
  exports.isObjectId = isObjectId;
25
25
  function _isObjectIdValue(input) {
26
- return (input instanceof Uint8Array && input.length === 12) ||
27
- (typeof input === 'string' && input.length === 24 && validator_1.default.isHexadecimal(input));
26
+ return ((input instanceof Uint8Array && input.length === 12) ||
27
+ (typeof input === 'string' && input.length === 24 && validator_1.default.isHexadecimal(input)));
28
28
  }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isPassportNumber = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is a passport number
31
+ * @validator isPassportNumber
32
+ */
33
+ function isPassportNumber(countryCode, options) {
34
+ return (0, index_js_1.validator)('isPassportNumber', function (input, context, _this) {
35
+ if (typeof input === 'string' && validatorJS.isPassportNumber(input, countryCode))
36
+ return input;
37
+ context.fail(_this, `"{{value}}" is not a valid ${countryCode} PassportNumber)`, input);
38
+ }, options);
39
+ }
40
+ exports.isPassportNumber = isPassportNumber;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isPort = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is a port number
31
+ * @validator isPort
32
+ */
33
+ function isPort(options) {
34
+ return (0, index_js_1.validator)('isPort', function (input, context, _this) {
35
+ if (input != null && typeof input === 'string' && validatorJS.isPort(input))
36
+ return input;
37
+ context.fail(_this, `{{label}} is not a valid port number`, input);
38
+ }, options);
39
+ }
40
+ exports.isPort = isPort;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isURL = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an URL
31
+ * @validator isURL
32
+ */
33
+ function isURL(options) {
34
+ return (0, index_js_1.validator)('isURL', function (input, context, _this) {
35
+ if (input != null && typeof input === 'string' && validatorJS.isURL(input, options))
36
+ return input;
37
+ context.fail(_this, `{{value}} is not a valid URL`, input);
38
+ }, options);
39
+ }
40
+ exports.isURL = isURL;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isUUID = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an "UUID".
31
+ * @validator isUUID
32
+ */
33
+ function isUUID(version, options) {
34
+ return (0, index_js_1.validator)('isUUID', function (input, context, _this) {
35
+ if (input != null && typeof input === 'string' && validatorJS.isUUID(input, version))
36
+ return input;
37
+ context.fail(_this, `{{label}} is not a valid UUID${version ? ' v' + version : ''}`, input);
38
+ }, options);
39
+ }
40
+ exports.isUUID = isUUID;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isVATNumber = void 0;
27
+ const validatorJS = __importStar(require("validator"));
28
+ const index_js_1 = require("../../core/index.js");
29
+ /**
30
+ * Validates if value is an VAT number
31
+ * @validator isVAT
32
+ */
33
+ function isVATNumber(countryCode, options) {
34
+ return (0, index_js_1.validator)('isVATNumber', function (input, context, _this) {
35
+ if (typeof input === 'string' && validatorJS.isVAT(input, countryCode))
36
+ return input;
37
+ context.fail(_this, `"{{value}}" is not a valid VAT number`, input);
38
+ }, options);
39
+ }
40
+ exports.isVATNumber = isVATNumber;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRegExp = void 0;
4
- const index_js_1 = require("../core/index.js");
3
+ exports.matches = void 0;
4
+ const index_js_1 = require("../../core/index.js");
5
5
  /**
6
6
  * Coerces given value to "UUID" format or returns undefined if nullish
7
7
  * @validator uuid
8
8
  */
9
- function isRegExp(format, options) {
9
+ function matches(format, options) {
10
10
  const regExp = format instanceof RegExp ? format : new RegExp(format);
11
11
  const formatName = options?.formatName;
12
12
  return (0, index_js_1.validator)('matches', function (input, context, _this) {
@@ -14,7 +14,10 @@ function isRegExp(format, options) {
14
14
  return;
15
15
  if (typeof input === 'string' && regExp.test(input))
16
16
  return input;
17
- context.fail(_this, `{{label}} does not match ${formatName || 'requested'} format`, input, { format, formatName });
17
+ context.fail(_this, `"{{value}}" does not match ${formatName || 'requested'} format`, input, {
18
+ format,
19
+ formatName,
20
+ });
18
21
  }, options);
19
22
  }
20
- exports.isRegExp = isRegExp;
23
+ exports.matches = matches;