valgen 5.5.0 → 5.7.0

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 (163) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/cjs/core/index.js +7 -20
  3. package/cjs/factories.js +2 -15
  4. package/cjs/index.js +10 -31
  5. package/cjs/rules/format-rules/is-alpha.js +2 -24
  6. package/cjs/rules/format-rules/is-ascii.js +2 -24
  7. package/cjs/rules/format-rules/is-base64.js +2 -24
  8. package/cjs/rules/format-rules/is-btc-address.js +2 -24
  9. package/cjs/rules/format-rules/is-credit-card.js +2 -24
  10. package/cjs/rules/format-rules/is-decimal.js +2 -24
  11. package/cjs/rules/format-rules/is-ean.js +2 -24
  12. package/cjs/rules/format-rules/is-email.js +2 -24
  13. package/cjs/rules/format-rules/is-eth-address.js +2 -24
  14. package/cjs/rules/format-rules/is-fqdn.js +2 -24
  15. package/cjs/rules/format-rules/is-hash.js +2 -24
  16. package/cjs/rules/format-rules/is-hex-color.js +2 -24
  17. package/cjs/rules/format-rules/is-hex.js +2 -24
  18. package/cjs/rules/format-rules/is-iban.js +2 -24
  19. package/cjs/rules/format-rules/is-ip.js +2 -24
  20. package/cjs/rules/format-rules/is-issn.js +2 -24
  21. package/cjs/rules/format-rules/is-jwt.js +2 -24
  22. package/cjs/rules/format-rules/is-lowercase.js +2 -24
  23. package/cjs/rules/format-rules/is-mac-address.js +2 -24
  24. package/cjs/rules/format-rules/is-mobile-phone.js +2 -24
  25. package/cjs/rules/format-rules/is-object-id.js +2 -4
  26. package/cjs/rules/format-rules/is-passport-number.js +2 -24
  27. package/cjs/rules/format-rules/is-port.js +2 -24
  28. package/cjs/rules/format-rules/is-url.js +2 -24
  29. package/cjs/rules/format-rules/is-uuid.js +2 -24
  30. package/cjs/rules/format-rules/is-vat-number.js +2 -24
  31. package/cjs/rules/index.js +51 -64
  32. package/cjs/rules/type-rules/is-null.js +30 -3
  33. package/esm/constants.js +5 -2
  34. package/esm/core/constants.js +5 -2
  35. package/esm/core/context.js +9 -5
  36. package/esm/core/index.js +9 -6
  37. package/esm/core/types.js +2 -1
  38. package/esm/core/utilities.js +10 -6
  39. package/esm/core/validation-error.js +5 -1
  40. package/esm/core/validator.js +18 -14
  41. package/esm/factories.js +4 -1
  42. package/esm/helpers/object.utils.js +6 -2
  43. package/esm/helpers/omit-undefined.js +4 -1
  44. package/esm/helpers/string.utils.js +4 -1
  45. package/esm/index.js +69 -4
  46. package/esm/rules/format-rules/is-alpha.js +11 -6
  47. package/esm/rules/format-rules/is-ascii.js +8 -4
  48. package/esm/rules/format-rules/is-base64.js +8 -4
  49. package/esm/rules/format-rules/is-btc-address.js +8 -4
  50. package/esm/rules/format-rules/is-credit-card.js +8 -4
  51. package/esm/rules/format-rules/is-decimal.js +8 -4
  52. package/esm/rules/format-rules/is-ean.js +8 -4
  53. package/esm/rules/format-rules/is-email.js +8 -4
  54. package/esm/rules/format-rules/is-eth-address.js +8 -4
  55. package/esm/rules/format-rules/is-fqdn.js +8 -4
  56. package/esm/rules/format-rules/is-hash.js +8 -4
  57. package/esm/rules/format-rules/is-hex-color.js +8 -4
  58. package/esm/rules/format-rules/is-hex.js +8 -4
  59. package/esm/rules/format-rules/is-iban.js +11 -6
  60. package/esm/rules/format-rules/is-ip.js +11 -6
  61. package/esm/rules/format-rules/is-issn.js +8 -4
  62. package/esm/rules/format-rules/is-jwt.js +8 -4
  63. package/esm/rules/format-rules/is-lowercase.js +11 -6
  64. package/esm/rules/format-rules/is-mac-address.js +8 -4
  65. package/esm/rules/format-rules/is-mobile-phone.js +8 -4
  66. package/esm/rules/format-rules/is-object-id.js +9 -5
  67. package/esm/rules/format-rules/is-passport-number.js +8 -4
  68. package/esm/rules/format-rules/is-port.js +8 -4
  69. package/esm/rules/format-rules/is-url.js +8 -4
  70. package/esm/rules/format-rules/is-uuid.js +8 -4
  71. package/esm/rules/format-rules/is-vat-number.js +8 -4
  72. package/esm/rules/format-rules/matches.js +6 -3
  73. package/esm/rules/index.js +53 -50
  74. package/esm/rules/logical-rules/is-defined.js +6 -3
  75. package/esm/rules/logical-rules/is-empty.js +9 -5
  76. package/esm/rules/logical-rules/range.js +29 -19
  77. package/esm/rules/type-rules/is-any.js +6 -2
  78. package/esm/rules/type-rules/is-array.js +6 -3
  79. package/esm/rules/type-rules/is-bigint.js +6 -3
  80. package/esm/rules/type-rules/is-boolean.js +6 -3
  81. package/esm/rules/type-rules/is-date.js +14 -10
  82. package/esm/rules/type-rules/is-enum.js +6 -3
  83. package/esm/rules/type-rules/is-integer.js +6 -3
  84. package/esm/rules/type-rules/is-null.js +39 -8
  85. package/esm/rules/type-rules/is-number.js +6 -3
  86. package/esm/rules/type-rules/is-object.js +14 -11
  87. package/esm/rules/type-rules/is-record.js +6 -3
  88. package/esm/rules/type-rules/is-string.js +22 -13
  89. package/esm/rules/type-rules/is-tuple.js +6 -3
  90. package/esm/rules/type-rules/is-undefined.js +6 -3
  91. package/esm/rules/utility-rules/exists.js +6 -3
  92. package/esm/rules/utility-rules/get-length.js +6 -3
  93. package/esm/rules/utility-rules/optional.js +6 -3
  94. package/esm/rules/utility-rules/pipe.js +9 -5
  95. package/esm/rules/utility-rules/required.js +6 -3
  96. package/esm/rules/utility-rules/union.js +6 -3
  97. package/package.json +16 -16
  98. package/{typings → types}/index.d.ts +3 -1
  99. package/types/rules/type-rules/is-null.d.ts +21 -0
  100. package/cjs/package.json +0 -3
  101. package/typings/rules/type-rules/is-null.d.ts +0 -11
  102. /package/{typings → types}/constants.d.ts +0 -0
  103. /package/{typings → types}/core/constants.d.ts +0 -0
  104. /package/{typings → types}/core/context.d.ts +0 -0
  105. /package/{typings → types}/core/index.d.ts +0 -0
  106. /package/{typings → types}/core/types.d.ts +0 -0
  107. /package/{typings → types}/core/utilities.d.ts +0 -0
  108. /package/{typings → types}/core/validation-error.d.ts +0 -0
  109. /package/{typings → types}/core/validator.d.ts +0 -0
  110. /package/{typings → types}/factories.d.ts +0 -0
  111. /package/{typings → types}/helpers/object.utils.d.ts +0 -0
  112. /package/{typings → types}/helpers/omit-undefined.d.ts +0 -0
  113. /package/{typings → types}/helpers/string.utils.d.ts +0 -0
  114. /package/{typings → types}/rules/format-rules/is-alpha.d.ts +0 -0
  115. /package/{typings → types}/rules/format-rules/is-ascii.d.ts +0 -0
  116. /package/{typings → types}/rules/format-rules/is-base64.d.ts +0 -0
  117. /package/{typings → types}/rules/format-rules/is-btc-address.d.ts +0 -0
  118. /package/{typings → types}/rules/format-rules/is-credit-card.d.ts +0 -0
  119. /package/{typings → types}/rules/format-rules/is-decimal.d.ts +0 -0
  120. /package/{typings → types}/rules/format-rules/is-ean.d.ts +0 -0
  121. /package/{typings → types}/rules/format-rules/is-email.d.ts +0 -0
  122. /package/{typings → types}/rules/format-rules/is-eth-address.d.ts +0 -0
  123. /package/{typings → types}/rules/format-rules/is-fqdn.d.ts +0 -0
  124. /package/{typings → types}/rules/format-rules/is-hash.d.ts +0 -0
  125. /package/{typings → types}/rules/format-rules/is-hex-color.d.ts +0 -0
  126. /package/{typings → types}/rules/format-rules/is-hex.d.ts +0 -0
  127. /package/{typings → types}/rules/format-rules/is-iban.d.ts +0 -0
  128. /package/{typings → types}/rules/format-rules/is-ip.d.ts +0 -0
  129. /package/{typings → types}/rules/format-rules/is-issn.d.ts +0 -0
  130. /package/{typings → types}/rules/format-rules/is-jwt.d.ts +0 -0
  131. /package/{typings → types}/rules/format-rules/is-lowercase.d.ts +0 -0
  132. /package/{typings → types}/rules/format-rules/is-mac-address.d.ts +0 -0
  133. /package/{typings → types}/rules/format-rules/is-mobile-phone.d.ts +0 -0
  134. /package/{typings → types}/rules/format-rules/is-object-id.d.ts +0 -0
  135. /package/{typings → types}/rules/format-rules/is-passport-number.d.ts +0 -0
  136. /package/{typings → types}/rules/format-rules/is-port.d.ts +0 -0
  137. /package/{typings → types}/rules/format-rules/is-url.d.ts +0 -0
  138. /package/{typings → types}/rules/format-rules/is-uuid.d.ts +0 -0
  139. /package/{typings → types}/rules/format-rules/is-vat-number.d.ts +0 -0
  140. /package/{typings → types}/rules/format-rules/matches.d.ts +0 -0
  141. /package/{typings → types}/rules/index.d.ts +0 -0
  142. /package/{typings → types}/rules/logical-rules/is-defined.d.ts +0 -0
  143. /package/{typings → types}/rules/logical-rules/is-empty.d.ts +0 -0
  144. /package/{typings → types}/rules/logical-rules/range.d.ts +0 -0
  145. /package/{typings → types}/rules/type-rules/is-any.d.ts +0 -0
  146. /package/{typings → types}/rules/type-rules/is-array.d.ts +0 -0
  147. /package/{typings → types}/rules/type-rules/is-bigint.d.ts +0 -0
  148. /package/{typings → types}/rules/type-rules/is-boolean.d.ts +0 -0
  149. /package/{typings → types}/rules/type-rules/is-date.d.ts +0 -0
  150. /package/{typings → types}/rules/type-rules/is-enum.d.ts +0 -0
  151. /package/{typings → types}/rules/type-rules/is-integer.d.ts +0 -0
  152. /package/{typings → types}/rules/type-rules/is-number.d.ts +0 -0
  153. /package/{typings → types}/rules/type-rules/is-object.d.ts +0 -0
  154. /package/{typings → types}/rules/type-rules/is-record.d.ts +0 -0
  155. /package/{typings → types}/rules/type-rules/is-string.d.ts +0 -0
  156. /package/{typings → types}/rules/type-rules/is-tuple.d.ts +0 -0
  157. /package/{typings → types}/rules/type-rules/is-undefined.d.ts +0 -0
  158. /package/{typings → types}/rules/utility-rules/exists.d.ts +0 -0
  159. /package/{typings → types}/rules/utility-rules/get-length.d.ts +0 -0
  160. /package/{typings → types}/rules/utility-rules/optional.d.ts +0 -0
  161. /package/{typings → types}/rules/utility-rules/pipe.d.ts +0 -0
  162. /package/{typings → types}/rules/utility-rules/required.d.ts +0 -0
  163. /package/{typings → types}/rules/utility-rules/union.d.ts +0 -0
@@ -1,11 +1,15 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isJWT = isJWT;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value a valid JWT token
5
9
  * @validator isJWT
6
10
  */
7
- export function isJWT(options) {
8
- return validator('isJWT', (input, context, _this) => {
11
+ function isJWT(options) {
12
+ return (0, index_js_1.validator)('isJWT', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isJWT(input))
10
14
  return input;
11
15
  context.fail(_this, `Value is not a valid JWT token`, input);
@@ -1,11 +1,16 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLowercase = isLowercase;
4
+ exports.isUppercase = isUppercase;
5
+ const tslib_1 = require("tslib");
6
+ const validatorJS = tslib_1.__importStar(require("validator"));
7
+ const index_js_1 = require("../../core/index.js");
3
8
  /**
4
9
  * Validates if value a Lowercase string
5
10
  * @validator isLowercase
6
11
  */
7
- export function isLowercase(options) {
8
- return validator('isLowercase', (input, context, _this) => {
12
+ function isLowercase(options) {
13
+ return (0, index_js_1.validator)('isLowercase', (input, context, _this) => {
9
14
  if (typeof input === 'string' && validatorJS.isLowercase(input)) {
10
15
  return input;
11
16
  }
@@ -16,8 +21,8 @@ export function isLowercase(options) {
16
21
  * Validates if value a Uppercase string
17
22
  * @validator isUppercase
18
23
  */
19
- export function isUppercase(options) {
20
- return validator('isUppercase', (input, context, _this) => {
24
+ function isUppercase(options) {
25
+ return (0, index_js_1.validator)('isUppercase', (input, context, _this) => {
21
26
  if (typeof input === 'string' && validatorJS.isUppercase(input)) {
22
27
  return input;
23
28
  }
@@ -1,16 +1,20 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMACAddress = isMACAddress;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is an MACAddress
5
9
  * @validator isMACAddress
6
10
  */
7
- export function isMACAddress(options) {
11
+ function isMACAddress(options) {
8
12
  const opts = {
9
13
  // eslint-disable-next-line camelcase
10
14
  no_separators: options?.noSeparators,
11
15
  eui: options?.eui,
12
16
  };
13
- return validator('isMACAddress', (input, context, _this) => {
17
+ return (0, index_js_1.validator)('isMACAddress', (input, context, _this) => {
14
18
  if (input != null &&
15
19
  typeof input === 'string' &&
16
20
  validatorJS.isMACAddress(input, opts)) {
@@ -1,14 +1,18 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMobilePhone = isMobilePhone;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is a valid Email
5
9
  * @validator isMobilePhone
6
10
  */
7
- export function isMobilePhone(options) {
11
+ function isMobilePhone(options) {
8
12
  const opts = {
9
13
  strictMode: options?.strictMode,
10
14
  };
11
- return validator('isMobilePhone', (input, context, _this) => {
15
+ return (0, index_js_1.validator)('isMobilePhone', (input, context, _this) => {
12
16
  if (typeof input === 'string' &&
13
17
  validatorJS.isMobilePhone(input, options?.locale, opts)) {
14
18
  return input;
@@ -1,11 +1,15 @@
1
- import validatorJS from 'validator';
2
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObjectId = isObjectId;
4
+ const tslib_1 = require("tslib");
5
+ const validator_1 = tslib_1.__importDefault(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is an "ObjectId".
5
9
  * @validator isObjectId
6
10
  */
7
- export function isObjectId(options) {
8
- return validator('isObjectId', (input, context, _this) => {
11
+ function isObjectId(options) {
12
+ return (0, index_js_1.validator)('isObjectId', (input, context, _this) => {
9
13
  if (input != null &&
10
14
  (_isObjectIdValue(input) ||
11
15
  (typeof input === 'object' &&
@@ -20,5 +24,5 @@ function _isObjectIdValue(input) {
20
24
  return ((input instanceof Uint8Array && input.length === 12) ||
21
25
  (typeof input === 'string' &&
22
26
  input.length === 24 &&
23
- validatorJS.isHexadecimal(input)));
27
+ validator_1.default.isHexadecimal(input)));
24
28
  }
@@ -1,11 +1,15 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPassportNumber = isPassportNumber;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is a passport number
5
9
  * @validator isPassportNumber
6
10
  */
7
- export function isPassportNumber(countryCode, options) {
8
- return validator('isPassportNumber', (input, context, _this) => {
11
+ function isPassportNumber(countryCode, options) {
12
+ return (0, index_js_1.validator)('isPassportNumber', (input, context, _this) => {
9
13
  if (typeof input === 'string' &&
10
14
  validatorJS.isPassportNumber(input, countryCode)) {
11
15
  return input;
@@ -1,11 +1,15 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPort = isPort;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is a port number
5
9
  * @validator isPort
6
10
  */
7
- export function isPort(options) {
8
- return validator('isPort', (input, context, _this) => {
11
+ function isPort(options) {
12
+ return (0, index_js_1.validator)('isPort', (input, context, _this) => {
9
13
  if (input != null &&
10
14
  typeof input === 'string' &&
11
15
  validatorJS.isPort(input)) {
@@ -1,11 +1,15 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isURL = isURL;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is an URL
5
9
  * @validator isURL
6
10
  */
7
- export function isURL(options) {
8
- return validator('isURL', (input, context, _this) => {
11
+ function isURL(options) {
12
+ return (0, index_js_1.validator)('isURL', (input, context, _this) => {
9
13
  if (input != null &&
10
14
  typeof input === 'string' &&
11
15
  validatorJS.isURL(input, options)) {
@@ -1,11 +1,15 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUUID = isUUID;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is an "UUID".
5
9
  * @validator isUUID
6
10
  */
7
- export function isUUID(version, options) {
8
- return validator('isUUID', (input, context, _this) => {
11
+ function isUUID(version, options) {
12
+ return (0, index_js_1.validator)('isUUID', (input, context, _this) => {
9
13
  if (input != null &&
10
14
  typeof input === 'string' &&
11
15
  validatorJS.isUUID(input, version)) {
@@ -1,11 +1,15 @@
1
- import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVATNumber = isVATNumber;
4
+ const tslib_1 = require("tslib");
5
+ const validatorJS = tslib_1.__importStar(require("validator"));
6
+ const index_js_1 = require("../../core/index.js");
3
7
  /**
4
8
  * Validates if value is an VAT number
5
9
  * @validator isVAT
6
10
  */
7
- export function isVATNumber(countryCode, options) {
8
- return validator('isVATNumber', (input, context, _this) => {
11
+ function isVATNumber(countryCode, options) {
12
+ return (0, index_js_1.validator)('isVATNumber', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isVAT(input, countryCode)) {
10
14
  return input;
11
15
  }
@@ -1,12 +1,15 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matches = matches;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Coerces given value to "UUID" format or returns undefined if nullish
4
7
  * @validator uuid
5
8
  */
6
- export function matches(format, options) {
9
+ function matches(format, options) {
7
10
  const regExp = format instanceof RegExp ? format : new RegExp(format);
8
11
  const formatName = options?.formatName;
9
- return validator('matches', (input, context, _this) => {
12
+ return (0, index_js_1.validator)('matches', (input, context, _this) => {
10
13
  if (input == null)
11
14
  return;
12
15
  if (typeof input === 'string' && regExp.test(input))
@@ -1,50 +1,53 @@
1
- export * from './format-rules/is-alpha.js';
2
- export * from './format-rules/is-ascii.js';
3
- export * from './format-rules/is-base64.js';
4
- export * from './format-rules/is-btc-address.js';
5
- export * from './format-rules/is-credit-card.js';
6
- export * from './format-rules/is-decimal.js';
7
- export * from './format-rules/is-ean.js';
8
- export * from './format-rules/is-email.js';
9
- export * from './format-rules/is-eth-address.js';
10
- export * from './format-rules/is-fqdn.js';
11
- export * from './format-rules/is-hash.js';
12
- export * from './format-rules/is-hex.js';
13
- export * from './format-rules/is-hex-color.js';
14
- export * from './format-rules/is-iban.js';
15
- export * from './format-rules/is-ip.js';
16
- export * from './format-rules/is-issn.js';
17
- export * from './format-rules/is-jwt.js';
18
- export * from './format-rules/is-lowercase.js';
19
- export * from './format-rules/is-mac-address.js';
20
- export * from './format-rules/is-mobile-phone.js';
21
- export * from './format-rules/is-object-id.js';
22
- export * from './format-rules/is-passport-number.js';
23
- export * from './format-rules/is-port.js';
24
- export * from './format-rules/is-url.js';
25
- export * from './format-rules/is-uuid.js';
26
- export * from './format-rules/is-vat-number.js';
27
- export * from './format-rules/matches.js';
28
- export * from './logical-rules/is-defined.js';
29
- export * from './logical-rules/is-empty.js';
30
- export * from './logical-rules/range.js';
31
- export * from './type-rules/is-any.js';
32
- export * from './type-rules/is-array.js';
33
- export * from './type-rules/is-bigint.js';
34
- export * from './type-rules/is-boolean.js';
35
- export * from './type-rules/is-date.js';
36
- export * from './type-rules/is-enum.js';
37
- export * from './type-rules/is-integer.js';
38
- export * from './type-rules/is-null.js';
39
- export * from './type-rules/is-number.js';
40
- export * from './type-rules/is-object.js';
41
- export * from './type-rules/is-record.js';
42
- export * from './type-rules/is-string.js';
43
- export * from './type-rules/is-tuple.js';
44
- export * from './type-rules/is-undefined.js';
45
- export * from './utility-rules/exists.js';
46
- export * from './utility-rules/get-length.js';
47
- export * from './utility-rules/optional.js';
48
- export * from './utility-rules/pipe.js';
49
- export * from './utility-rules/required.js';
50
- export * from './utility-rules/union.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./format-rules/is-alpha.js"), exports);
5
+ tslib_1.__exportStar(require("./format-rules/is-ascii.js"), exports);
6
+ tslib_1.__exportStar(require("./format-rules/is-base64.js"), exports);
7
+ tslib_1.__exportStar(require("./format-rules/is-btc-address.js"), exports);
8
+ tslib_1.__exportStar(require("./format-rules/is-credit-card.js"), exports);
9
+ tslib_1.__exportStar(require("./format-rules/is-decimal.js"), exports);
10
+ tslib_1.__exportStar(require("./format-rules/is-ean.js"), exports);
11
+ tslib_1.__exportStar(require("./format-rules/is-email.js"), exports);
12
+ tslib_1.__exportStar(require("./format-rules/is-eth-address.js"), exports);
13
+ tslib_1.__exportStar(require("./format-rules/is-fqdn.js"), exports);
14
+ tslib_1.__exportStar(require("./format-rules/is-hash.js"), exports);
15
+ tslib_1.__exportStar(require("./format-rules/is-hex.js"), exports);
16
+ tslib_1.__exportStar(require("./format-rules/is-hex-color.js"), exports);
17
+ tslib_1.__exportStar(require("./format-rules/is-iban.js"), exports);
18
+ tslib_1.__exportStar(require("./format-rules/is-ip.js"), exports);
19
+ tslib_1.__exportStar(require("./format-rules/is-issn.js"), exports);
20
+ tslib_1.__exportStar(require("./format-rules/is-jwt.js"), exports);
21
+ tslib_1.__exportStar(require("./format-rules/is-lowercase.js"), exports);
22
+ tslib_1.__exportStar(require("./format-rules/is-mac-address.js"), exports);
23
+ tslib_1.__exportStar(require("./format-rules/is-mobile-phone.js"), exports);
24
+ tslib_1.__exportStar(require("./format-rules/is-object-id.js"), exports);
25
+ tslib_1.__exportStar(require("./format-rules/is-passport-number.js"), exports);
26
+ tslib_1.__exportStar(require("./format-rules/is-port.js"), exports);
27
+ tslib_1.__exportStar(require("./format-rules/is-url.js"), exports);
28
+ tslib_1.__exportStar(require("./format-rules/is-uuid.js"), exports);
29
+ tslib_1.__exportStar(require("./format-rules/is-vat-number.js"), exports);
30
+ tslib_1.__exportStar(require("./format-rules/matches.js"), exports);
31
+ tslib_1.__exportStar(require("./logical-rules/is-defined.js"), exports);
32
+ tslib_1.__exportStar(require("./logical-rules/is-empty.js"), exports);
33
+ tslib_1.__exportStar(require("./logical-rules/range.js"), exports);
34
+ tslib_1.__exportStar(require("./type-rules/is-any.js"), exports);
35
+ tslib_1.__exportStar(require("./type-rules/is-array.js"), exports);
36
+ tslib_1.__exportStar(require("./type-rules/is-bigint.js"), exports);
37
+ tslib_1.__exportStar(require("./type-rules/is-boolean.js"), exports);
38
+ tslib_1.__exportStar(require("./type-rules/is-date.js"), exports);
39
+ tslib_1.__exportStar(require("./type-rules/is-enum.js"), exports);
40
+ tslib_1.__exportStar(require("./type-rules/is-integer.js"), exports);
41
+ tslib_1.__exportStar(require("./type-rules/is-null.js"), exports);
42
+ tslib_1.__exportStar(require("./type-rules/is-number.js"), exports);
43
+ tslib_1.__exportStar(require("./type-rules/is-object.js"), exports);
44
+ tslib_1.__exportStar(require("./type-rules/is-record.js"), exports);
45
+ tslib_1.__exportStar(require("./type-rules/is-string.js"), exports);
46
+ tslib_1.__exportStar(require("./type-rules/is-tuple.js"), exports);
47
+ tslib_1.__exportStar(require("./type-rules/is-undefined.js"), exports);
48
+ tslib_1.__exportStar(require("./utility-rules/exists.js"), exports);
49
+ tslib_1.__exportStar(require("./utility-rules/get-length.js"), exports);
50
+ tslib_1.__exportStar(require("./utility-rules/optional.js"), exports);
51
+ tslib_1.__exportStar(require("./utility-rules/pipe.js"), exports);
52
+ tslib_1.__exportStar(require("./utility-rules/required.js"), exports);
53
+ tslib_1.__exportStar(require("./utility-rules/union.js"), exports);
@@ -1,10 +1,13 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDefined = isDefined;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates if value is not "undefined" nor "null"
4
7
  * @validator isDefined
5
8
  */
6
- export function isDefined(options) {
7
- return validator('is-defined', (input, context, _this) => {
9
+ function isDefined(options) {
10
+ return (0, index_js_1.validator)('is-defined', (input, context, _this) => {
8
11
  if (input !== undefined)
9
12
  return input;
10
13
  context.fail(_this, `Is not defined`, input);
@@ -1,10 +1,14 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmpty = isEmpty;
4
+ exports.isNotEmpty = isNotEmpty;
5
+ const index_js_1 = require("../../core/index.js");
2
6
  /**
3
7
  * Checks if value is an empty. Value should be string, array, set, map or object
4
8
  * @validator isEmpty
5
9
  */
6
- export function isEmpty(options) {
7
- return validator('isEmpty', (input, context, _this) => {
10
+ function isEmpty(options) {
11
+ return (0, index_js_1.validator)('isEmpty', (input, context, _this) => {
8
12
  if (input == null)
9
13
  return input;
10
14
  if (typeof input === 'string') {
@@ -39,8 +43,8 @@ export function isEmpty(options) {
39
43
  * Checks if value is a not empty. Value should be string, array, set, map or object
40
44
  * @validator isNotEmpty
41
45
  */
42
- export function isNotEmpty(options) {
43
- return validator('isNotEmpty', (input, context, _this) => {
46
+ function isNotEmpty(options) {
47
+ return (0, index_js_1.validator)('isNotEmpty', (input, context, _this) => {
44
48
  if (input != null) {
45
49
  if (typeof input === 'string') {
46
50
  if (input)
@@ -1,12 +1,20 @@
1
- import { validator, } from '../../core/index.js';
2
- import { getLength } from '../utility-rules/get-length.js';
3
- import { allOf, pipe } from '../utility-rules/pipe.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lengthMax = exports.lengthMin = void 0;
4
+ exports.range = range;
5
+ exports.isGt = isGt;
6
+ exports.isGte = isGte;
7
+ exports.isLt = isLt;
8
+ exports.isLte = isLte;
9
+ const index_js_1 = require("../../core/index.js");
10
+ const get_length_js_1 = require("../utility-rules/get-length.js");
11
+ const pipe_js_1 = require("../utility-rules/pipe.js");
4
12
  /**
5
13
  * Checks if value is between minValue and maxValue
6
14
  * @validator range
7
15
  */
8
- export function range(minValue, maxValue, options) {
9
- return validator('range', (input, context, _this) => {
16
+ function range(minValue, maxValue, options) {
17
+ return (0, index_js_1.validator)('range', (input, context, _this) => {
10
18
  if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
11
19
  (typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
12
20
  (typeof input === 'number' || typeof input === 'bigint') &&
@@ -31,8 +39,8 @@ export function range(minValue, maxValue, options) {
31
39
  context.fail(_this, `Value must be between ${minValue} and ${maxValue}`, input);
32
40
  }, options);
33
41
  }
34
- export function isGt(minValue, options) {
35
- return validator('isGt', (input, context, _this) => {
42
+ function isGt(minValue, options) {
43
+ return (0, index_js_1.validator)('isGt', (input, context, _this) => {
36
44
  if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
37
45
  (typeof input === 'number' || typeof input === 'bigint') &&
38
46
  input > minValue) {
@@ -53,8 +61,8 @@ export function isGt(minValue, options) {
53
61
  context.fail(_this, `{{label}} must be greater than ${typeof minValue === 'string' ? `"${minValue}"` : minValue}`, input);
54
62
  }, options);
55
63
  }
56
- export function isGte(minValue, options) {
57
- return validator('isGte', (input, context, _this) => {
64
+ function isGte(minValue, options) {
65
+ return (0, index_js_1.validator)('isGte', (input, context, _this) => {
58
66
  if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
59
67
  (typeof input === 'number' || typeof input === 'bigint') &&
60
68
  input >= minValue) {
@@ -75,8 +83,8 @@ export function isGte(minValue, options) {
75
83
  context.fail(_this, `{{label}} must be greater than or equal to ${typeof minValue === 'string' ? `"${minValue}"` : minValue}`, input);
76
84
  }, options);
77
85
  }
78
- export function isLt(maxValue, options) {
79
- return validator('isLt', (input, context, _this) => {
86
+ function isLt(maxValue, options) {
87
+ return (0, index_js_1.validator)('isLt', (input, context, _this) => {
80
88
  if ((typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
81
89
  (typeof input === 'number' || typeof input === 'bigint') &&
82
90
  input < maxValue) {
@@ -97,8 +105,8 @@ export function isLt(maxValue, options) {
97
105
  context.fail(_this, `{{label}} must be lover than ${typeof maxValue === 'string' ? `"${maxValue}"` : maxValue}`, input);
98
106
  }, options);
99
107
  }
100
- export function isLte(maxValue, options) {
101
- return validator('isLte', (input, context, _this) => {
108
+ function isLte(maxValue, options) {
109
+ return (0, index_js_1.validator)('isLte', (input, context, _this) => {
102
110
  if ((typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
103
111
  (typeof input === 'number' || typeof input === 'bigint') &&
104
112
  input <= maxValue) {
@@ -123,23 +131,25 @@ export function isLte(maxValue, options) {
123
131
  * Checks the length is at least "minValue"
124
132
  * @validator lengthMin
125
133
  */
126
- export const lengthMin = (minValue) => allOf([
127
- pipe([
128
- getLength(),
134
+ const lengthMin = (minValue) => (0, pipe_js_1.allOf)([
135
+ (0, pipe_js_1.pipe)([
136
+ (0, get_length_js_1.getLength)(),
129
137
  isGte(minValue, {
130
138
  onFail: () => `The length of {{label}} must be at least ${minValue}`,
131
139
  }),
132
140
  ]),
133
141
  ]);
142
+ exports.lengthMin = lengthMin;
134
143
  /**
135
144
  * Checks if the length is at most "maxValue"
136
145
  * @validator lengthMax
137
146
  */
138
- export const lengthMax = (maxValue) => allOf([
139
- pipe([
140
- getLength(),
147
+ const lengthMax = (maxValue) => (0, pipe_js_1.allOf)([
148
+ (0, pipe_js_1.pipe)([
149
+ (0, get_length_js_1.getLength)(),
141
150
  isLte(maxValue, {
142
151
  onFail: () => `The length of {{label}} must be at most ${maxValue}`,
143
152
  }),
144
153
  ]),
145
154
  ]);
155
+ exports.lengthMax = lengthMax;
@@ -1,6 +1,10 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAny = void 0;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Does nothing, just returns original input value.
4
7
  * @validator isAny
5
8
  */
6
- export const isAny = () => validator('is-any', (input) => input);
9
+ const isAny = () => (0, index_js_1.validator)('is-any', (input) => input);
10
+ exports.isAny = isAny;
@@ -1,11 +1,14 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArray = isArray;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates if value is "array" and applies validation for each item.
4
7
  * Converts input value to array if coerce option is set to 'true'.
5
8
  * @validator isArray
6
9
  */
7
- export function isArray(itemValidator, options) {
8
- return validator('isArray', (input, context, _this) => {
10
+ function isArray(itemValidator, options) {
11
+ return (0, index_js_1.validator)('isArray', (input, context, _this) => {
9
12
  const coerce = options?.coerce || context.coerce;
10
13
  let output = input;
11
14
  if (output != null && coerce && !Array.isArray(output))
@@ -1,11 +1,14 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBigint = isBigint;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates if value is "BigInt".
4
7
  * Converts input value to number if coerce option is set to 'true'.
5
8
  * @validator isNumber
6
9
  */
7
- export function isBigint(options) {
8
- return validator('isBigint', (input, context, _this) => {
10
+ function isBigint(options) {
11
+ return (0, index_js_1.validator)('isBigint', (input, context, _this) => {
9
12
  const coerce = options?.coerce || context.coerce;
10
13
  if (typeof input === 'bigint')
11
14
  return input;
@@ -1,4 +1,7 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBoolean = isBoolean;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  const TRUE_PATTERN = /^true|t|1|yes|y$/i;
3
6
  const FALSE_PATTERN = /^false|f|0|no|n$/i;
4
7
  /**
@@ -6,8 +9,8 @@ const FALSE_PATTERN = /^false|f|0|no|n$/i;
6
9
  * Converts input value to boolean if coerce option is set to 'true'.
7
10
  * @validator isBoolean
8
11
  */
9
- export function isBoolean(options) {
10
- return validator('isBoolean', (input, context, _this) => {
12
+ function isBoolean(options) {
13
+ return (0, index_js_1.validator)('isBoolean', (input, context, _this) => {
11
14
  const coerce = options?.coerce || context.coerce;
12
15
  let output = input;
13
16
  if (output != null && typeof output !== 'boolean' && coerce) {