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,7 +1,11 @@
1
- export class ValidationError extends Error {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationError = void 0;
4
+ class ValidationError extends Error {
2
5
  constructor(issues) {
3
6
  super(issues[0].message);
4
7
  this.issues = [];
5
8
  this.issues = issues;
6
9
  }
7
10
  }
11
+ exports.ValidationError = ValidationError;
@@ -1,9 +1,13 @@
1
- import { camelCase } from '../helpers/string.utils.js';
2
- import { kOptions, kValidatorFn } from './constants.js';
3
- import { Context } from './context.js';
4
- import { ValidationError } from './validation-error.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validator = validator;
4
+ exports.isValidator = isValidator;
5
+ const string_utils_js_1 = require("../helpers/string.utils.js");
6
+ const constants_js_1 = require("./constants.js");
7
+ const context_js_1 = require("./context.js");
8
+ const validation_error_js_1 = require("./validation-error.js");
5
9
  let unnamedValidatorIndex = 0;
6
- export function validator(arg0, arg1, arg2) {
10
+ function validator(arg0, arg1, arg2) {
7
11
  let id = '';
8
12
  let fn;
9
13
  let validatorOptions;
@@ -20,31 +24,31 @@ export function validator(arg0, arg1, arg2) {
20
24
  throw new TypeError('You must provide a rule function argument');
21
25
  }
22
26
  id = id || fn.name || 'validator' + ++unnamedValidatorIndex;
23
- const name = fn.name || camelCase(id);
27
+ const name = fn.name || (0, string_utils_js_1.camelCase)(id);
24
28
  const _rule = {
25
29
  [name](input, options) {
26
- const ctx = options instanceof Context ? options : undefined;
30
+ const ctx = options instanceof context_js_1.Context ? options : undefined;
27
31
  const opts = ctx ? undefined : options;
28
32
  const context = ctx?.extend({ ...validatorOptions, ...opts }) ||
29
- new Context({ ...validatorOptions, ...opts });
33
+ new context_js_1.Context({ ...validatorOptions, ...opts });
30
34
  let value;
31
35
  try {
32
36
  value = fn(input, context, _rule);
33
37
  }
34
38
  catch (e) {
35
- if (e instanceof ValidationError)
39
+ if (e instanceof validation_error_js_1.ValidationError)
36
40
  throw e;
37
41
  context.fail(_rule, e, input);
38
42
  }
39
43
  if (!ctx && context.errors.length) {
40
- throw new ValidationError(context.errors);
44
+ throw new validation_error_js_1.ValidationError(context.errors);
41
45
  }
42
46
  return value;
43
47
  },
44
48
  }[name];
45
49
  _rule.id = id;
46
- _rule[kValidatorFn] = fn;
47
- _rule[kOptions] = validatorOptions || {};
50
+ _rule[constants_js_1.kValidatorFn] = fn;
51
+ _rule[constants_js_1.kOptions] = validatorOptions || {};
48
52
  _rule.silent = (input, options, context) => {
49
53
  try {
50
54
  const value = _rule(input, options, context);
@@ -56,6 +60,6 @@ export function validator(arg0, arg1, arg2) {
56
60
  };
57
61
  return _rule;
58
62
  }
59
- export function isValidator(x) {
60
- return !!(typeof x === 'function' && x.id && x[kValidatorFn]);
63
+ function isValidator(x) {
64
+ return !!(typeof x === 'function' && x.id && x[constants_js_1.kValidatorFn]);
61
65
  }
package/esm/factories.js CHANGED
@@ -1 +1,4 @@
1
- export * from './rules/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./rules/index.js"), exports);
@@ -1,11 +1,15 @@
1
- export function omitKeys(o, keys) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omitKeys = omitKeys;
4
+ exports.pickKeys = pickKeys;
5
+ function omitKeys(o, keys) {
2
6
  return Object.keys(o).reduce((a, k) => {
3
7
  if (!keys.includes(k))
4
8
  a[k] = o[k];
5
9
  return a;
6
10
  }, {});
7
11
  }
8
- export function pickKeys(o, keys) {
12
+ function pickKeys(o, keys) {
9
13
  return Object.keys(o).reduce((a, k) => {
10
14
  if (keys.includes(k))
11
15
  a[k] = o[k];
@@ -1,4 +1,7 @@
1
- export function omitUndefined(obj, recursive) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omitUndefined = omitUndefined;
4
+ function omitUndefined(obj, recursive) {
2
5
  if (!(obj && typeof obj === 'object'))
3
6
  return obj;
4
7
  for (const k of Object.keys(obj)) {
@@ -1,3 +1,6 @@
1
- export function camelCase(v) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.camelCase = camelCase;
4
+ function camelCase(v) {
2
5
  return v.replace(/[\W_\s]+([^\W_\s])/g, (arg$, c) => c[0].toUpperCase());
3
6
  }
package/esm/index.js CHANGED
@@ -1,60 +1,125 @@
1
- import * as vg from './rules/index.js';
2
- export * from './constants.js';
3
- export * from './core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUUID5 = exports.isUUID4 = exports.isUUID3 = exports.isUUID2 = exports.isUUID1 = exports.isUUID = exports.isURL = exports.isUppercase = exports.isUndefined = exports.isSWIFT = exports.isString = exports.isPort = exports.isObjectId = exports.isObject = exports.isNumber = exports.isNullish = exports.isNull = exports.isNotNullish = exports.isNotNull = exports.isNotEmpty = exports.isMobilePhone = exports.isMACAddress = exports.isLowercase = exports.isJWT = exports.isISSN = exports.isIPRange = exports.isIP = exports.isInteger = exports.isIBAN = exports.isHexColor = exports.isHex = exports.isFQDN = exports.isETHAddress = exports.isEmpty = exports.isEmail = exports.isEAN = exports.isDefined = exports.isDecimal = exports.isDateString = exports.isDate = exports.isCreditCard = exports.isBtcAddress = exports.isBoolean = exports.isBigint = exports.isBase64 = exports.isAscii = exports.isArray = exports.isAny = exports.isAlphanumeric = exports.isAlpha = void 0;
4
+ exports.vg = exports.toString = exports.toNumber = exports.toInteger = exports.toDateString = exports.toDate = exports.toBoolean = exports.toBigint = exports.toArray = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const vg = tslib_1.__importStar(require("./rules/index.js"));
7
+ exports.vg = vg;
8
+ tslib_1.__exportStar(require("./constants.js"), exports);
9
+ tslib_1.__exportStar(require("./core/index.js"), exports);
4
10
  const isAny = vg.isAny();
11
+ exports.isAny = isAny;
5
12
  const isArray = vg.isArray();
13
+ exports.isArray = isArray;
6
14
  const isBigint = vg.isBigint();
15
+ exports.isBigint = isBigint;
7
16
  const isBoolean = vg.isBoolean();
17
+ exports.isBoolean = isBoolean;
8
18
  const isDate = vg.isDate();
19
+ exports.isDate = isDate;
9
20
  const isDateString = vg.isDateString();
21
+ exports.isDateString = isDateString;
10
22
  const isEmpty = vg.isEmpty();
23
+ exports.isEmpty = isEmpty;
11
24
  const isNotEmpty = vg.isNotEmpty();
25
+ exports.isNotEmpty = isNotEmpty;
12
26
  const isInteger = vg.isInteger();
27
+ exports.isInteger = isInteger;
13
28
  const isNull = vg.isNull();
29
+ exports.isNull = isNull;
30
+ const isNotNull = vg.isNotNull();
31
+ exports.isNotNull = isNotNull;
14
32
  const isNullish = vg.isNullish();
33
+ exports.isNullish = isNullish;
34
+ const isNotNullish = vg.isNotNullish();
35
+ exports.isNotNullish = isNotNullish;
15
36
  const isDefined = vg.isDefined();
37
+ exports.isDefined = isDefined;
16
38
  const isUndefined = vg.isUndefined();
39
+ exports.isUndefined = isUndefined;
17
40
  const isNumber = vg.isNumber();
41
+ exports.isNumber = isNumber;
18
42
  const isObject = vg.isObject();
43
+ exports.isObject = isObject;
19
44
  const isObjectId = vg.isObjectId();
45
+ exports.isObjectId = isObjectId;
20
46
  const isString = vg.isString();
47
+ exports.isString = isString;
21
48
  const isUUID = vg.isUUID();
49
+ exports.isUUID = isUUID;
22
50
  const isUUID1 = vg.isUUID(1);
51
+ exports.isUUID1 = isUUID1;
23
52
  const isUUID2 = vg.isUUID(2);
53
+ exports.isUUID2 = isUUID2;
24
54
  const isUUID3 = vg.isUUID(3);
55
+ exports.isUUID3 = isUUID3;
25
56
  const isUUID4 = vg.isUUID(4);
57
+ exports.isUUID4 = isUUID4;
26
58
  const isUUID5 = vg.isUUID(5);
59
+ exports.isUUID5 = isUUID5;
27
60
  const isEmail = vg.isEmail();
61
+ exports.isEmail = isEmail;
28
62
  const isMobilePhone = vg.isMobilePhone();
63
+ exports.isMobilePhone = isMobilePhone;
29
64
  const isIP = vg.isIP();
65
+ exports.isIP = isIP;
30
66
  const isIPRange = vg.isIPRange();
67
+ exports.isIPRange = isIPRange;
31
68
  const isMACAddress = vg.isMACAddress();
69
+ exports.isMACAddress = isMACAddress;
32
70
  const isPort = vg.isPort();
71
+ exports.isPort = isPort;
33
72
  const isURL = vg.isURL();
73
+ exports.isURL = isURL;
34
74
  const isBase64 = vg.isBase64();
75
+ exports.isBase64 = isBase64;
35
76
  const isSWIFT = vg.isSWIFT();
77
+ exports.isSWIFT = isSWIFT;
36
78
  const isCreditCard = vg.isCreditCard();
79
+ exports.isCreditCard = isCreditCard;
37
80
  const isIBAN = vg.isIBAN();
81
+ exports.isIBAN = isIBAN;
38
82
  const isEAN = vg.isEAN();
83
+ exports.isEAN = isEAN;
39
84
  const isFQDN = vg.isFQDN();
85
+ exports.isFQDN = isFQDN;
40
86
  const isISSN = vg.isISSN();
87
+ exports.isISSN = isISSN;
41
88
  const isBtcAddress = vg.isBtcAddress();
89
+ exports.isBtcAddress = isBtcAddress;
42
90
  const isETHAddress = vg.isETHAddress();
91
+ exports.isETHAddress = isETHAddress;
43
92
  const isHexColor = vg.isHexColor();
93
+ exports.isHexColor = isHexColor;
44
94
  const isJWT = vg.isJWT();
95
+ exports.isJWT = isJWT;
45
96
  const isLowercase = vg.isLowercase();
97
+ exports.isLowercase = isLowercase;
46
98
  const isUppercase = vg.isUppercase();
99
+ exports.isUppercase = isUppercase;
47
100
  const isAlpha = vg.isAlpha();
101
+ exports.isAlpha = isAlpha;
48
102
  const isAlphanumeric = vg.isAlphanumeric();
103
+ exports.isAlphanumeric = isAlphanumeric;
49
104
  const isAscii = vg.isAscii();
105
+ exports.isAscii = isAscii;
50
106
  const isDecimal = vg.isDecimal();
107
+ exports.isDecimal = isDecimal;
51
108
  const isHex = vg.isHex();
109
+ exports.isHex = isHex;
52
110
  const toArray = vg.isArray(isAny, { coerce: true });
111
+ exports.toArray = toArray;
53
112
  const toBoolean = vg.isBoolean({ coerce: true });
113
+ exports.toBoolean = toBoolean;
54
114
  const toDate = vg.isDate({ coerce: true });
115
+ exports.toDate = toDate;
55
116
  const toBigint = vg.isBigint({ coerce: true });
117
+ exports.toBigint = toBigint;
56
118
  const toDateString = vg.isDateString({ coerce: true });
119
+ exports.toDateString = toDateString;
57
120
  const toInteger = vg.isInteger({ coerce: true });
121
+ exports.toInteger = toInteger;
58
122
  const toNumber = vg.isNumber({ coerce: true });
123
+ exports.toNumber = toNumber;
59
124
  const toString = vg.isString({ coerce: true });
60
- export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, vg, };
125
+ exports.toString = toString;
@@ -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.isAlpha = isAlpha;
4
+ exports.isAlphanumeric = isAlphanumeric;
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
  * Check if the string contains only letters (a-zA-Z).
5
10
  * @validator isAlpha
6
11
  */
7
- export function isAlpha(options) {
8
- return validator('isLowercase', (input, context, _this) => {
12
+ function isAlpha(options) {
13
+ return (0, index_js_1.validator)('isLowercase', (input, context, _this) => {
9
14
  if (typeof input === 'string' && validatorJS.isAlpha(input))
10
15
  return input;
11
16
  context.fail(_this, `"{{value}}" is not an alpha string`, input);
@@ -15,8 +20,8 @@ export function isAlpha(options) {
15
20
  * Check if the string contains only letters and numbers.
16
21
  * @validator isAlphanumeric
17
22
  */
18
- export function isAlphanumeric(options) {
19
- return validator('isAlphanumeric', (input, context, _this) => {
23
+ function isAlphanumeric(options) {
24
+ return (0, index_js_1.validator)('isAlphanumeric', (input, context, _this) => {
20
25
  if (typeof input === 'string' && validatorJS.isAlphanumeric(input)) {
21
26
  return input;
22
27
  }
@@ -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.isAscii = isAscii;
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
  * Check if the string contains ASCII chars only.
5
9
  * @validator isAscii
6
10
  */
7
- export function isAscii(options) {
8
- return validator('isAscii', (input, context, _this) => {
11
+ function isAscii(options) {
12
+ return (0, index_js_1.validator)('isAscii', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isAscii(input))
10
14
  return input;
11
15
  context.fail(_this, `Value is not an ascii string`, 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.isBase64 = isBase64;
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 "Base64" string.
5
9
  * @validator isBase64
6
10
  */
7
- export function isBase64(options) {
8
- return validator('isBase64', (input, context, _this) => {
11
+ function isBase64(options) {
12
+ return (0, index_js_1.validator)('isBase64', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isBase64(input, options)) {
10
14
  return input;
11
15
  }
@@ -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.isBtcAddress = isBtcAddress;
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 BTC address.
5
9
  * @validator isBtcAddress
6
10
  */
7
- export function isBtcAddress(options) {
8
- return validator('isBtcAddress', (input, context, _this) => {
11
+ function isBtcAddress(options) {
12
+ return (0, index_js_1.validator)('isBtcAddress', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isBtcAddress(input)) {
10
14
  return input;
11
15
  }
@@ -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.isCreditCard = isCreditCard;
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 credit card number
5
9
  * @validator isCreditCard
6
10
  */
7
- export function isCreditCard(options) {
8
- return validator('isCreditCard', (input, context, _this) => {
11
+ function isCreditCard(options) {
12
+ return (0, index_js_1.validator)('isCreditCard', (input, context, _this) => {
9
13
  if (typeof input === 'string' &&
10
14
  validatorJS.isCreditCard(input, options)) {
11
15
  return input;
@@ -1,12 +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.isDecimal = isDecimal;
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
  * Check if the string represents a decimal number,
5
9
  * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
6
10
  * @validator isDecimal
7
11
  */
8
- export function isDecimal(options) {
9
- return validator('isDecimal', (input, context, _this) => {
12
+ function isDecimal(options) {
13
+ return (0, index_js_1.validator)('isDecimal', (input, context, _this) => {
10
14
  if (typeof input === 'string' && validatorJS.isDecimal(input)) {
11
15
  return input;
12
16
  }
@@ -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.isEAN = isEAN;
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 EAN (European Article Number)
5
9
  * @validator isEAN
6
10
  */
7
- export function isEAN(options) {
8
- return validator('isEAN', (input, context, _this) => {
11
+ function isEAN(options) {
12
+ return (0, index_js_1.validator)('isEAN', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isEAN(input))
10
14
  return input;
11
15
  context.fail(_this, `"{{value}}" is not a valid EAN (European Article Number)`, input);
@@ -1,10 +1,14 @@
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.isEmail = isEmail;
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 isEmail
6
10
  */
7
- export function isEmail(options) {
11
+ function isEmail(options) {
8
12
  const emailOptions = {
9
13
  // eslint-disable-next-line camelcase
10
14
  allow_display_name: true,
@@ -15,7 +19,7 @@ export function isEmail(options) {
15
19
  // eslint-disable-next-line camelcase
16
20
  allow_ip_domain: options?.allowIpDomain,
17
21
  };
18
- return validator('isEmail', (input, context, _this) => {
22
+ return (0, index_js_1.validator)('isEmail', (input, context, _this) => {
19
23
  if (typeof input === 'string' &&
20
24
  validatorJS.isEmail(input, emailOptions)) {
21
25
  if (options?.requireDisplayName) {
@@ -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.isETHAddress = isETHAddress;
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 ETH (Ethereum) address.
5
9
  * @validator isETHAddress
6
10
  */
7
- export function isETHAddress(options) {
8
- return validator('isETHAddress', (input, context, _this) => {
11
+ function isETHAddress(options) {
12
+ return (0, index_js_1.validator)('isETHAddress', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isEthereumAddress(input)) {
10
14
  return input;
11
15
  }
@@ -1,15 +1,19 @@
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.isFQDN = isFQDN;
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 FQDN
5
9
  * @validator isFQDN
6
10
  */
7
- export function isFQDN(options) {
11
+ function isFQDN(options) {
8
12
  const opts = {
9
13
  // eslint-disable-next-line camelcase
10
14
  allow_wildcard: options?.allowWildcard,
11
15
  };
12
- return validator('isFQDN', (input, context, _this) => {
16
+ return (0, index_js_1.validator)('isFQDN', (input, context, _this) => {
13
17
  if (typeof input === 'string' && validatorJS.isFQDN(input, opts)) {
14
18
  return input;
15
19
  }
@@ -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.isHash = isHash;
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 hash of type algorithm
5
9
  * @validator isHash
6
10
  */
7
- export function isHash(algorithm, options) {
8
- return validator('isHash', (input, context, _this) => {
11
+ function isHash(algorithm, options) {
12
+ return (0, index_js_1.validator)('isHash', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isHash(input, algorithm)) {
10
14
  return input;
11
15
  }
@@ -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.isHexColor = isHexColor;
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 Hex Color
5
9
  * @validator isHexColor
6
10
  */
7
- export function isHexColor(options) {
8
- return validator('isHexColor', (input, context, _this) => {
11
+ function isHexColor(options) {
12
+ return (0, index_js_1.validator)('isHexColor', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isHexColor(input)) {
10
14
  return input;
11
15
  }
@@ -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.isHex = isHex;
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
  * Check if the string is a hexadecimal number.
5
9
  * @validator isHex
6
10
  */
7
- export function isHex(options) {
8
- return validator('isHex', (input, context, _this) => {
11
+ function isHex(options) {
12
+ return (0, index_js_1.validator)('isHex', (input, context, _this) => {
9
13
  if (typeof input === 'string' && validatorJS.isHexadecimal(input)) {
10
14
  return input;
11
15
  }
@@ -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.isIBAN = isIBAN;
4
+ exports.isSWIFT = isSWIFT;
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 is an IBAN (International Bank Account Number)
5
10
  * @validator isIBAN
6
11
  */
7
- export function isIBAN(options) {
8
- return validator('isIBAN', (input, context, _this) => {
12
+ function isIBAN(options) {
13
+ return (0, index_js_1.validator)('isIBAN', (input, context, _this) => {
9
14
  if (typeof input === 'string' && validatorJS.isIBAN(input))
10
15
  return input;
11
16
  context.fail(_this, `{{label}} is not a valid IBAN (International Bank Account Number)`, input);
@@ -15,8 +20,8 @@ export function isIBAN(options) {
15
20
  * Validates if value is a BIC (Bank Identification Code) or SWIFT code
16
21
  * @validator isSWIFT
17
22
  */
18
- export function isSWIFT(options) {
19
- return validator('isSWIFT', (input, context, _this) => {
23
+ function isSWIFT(options) {
24
+ return (0, index_js_1.validator)('isSWIFT', (input, context, _this) => {
20
25
  if (typeof input === 'string' && validatorJS.isBIC(input))
21
26
  return input;
22
27
  context.fail(_this, `{{label}}is not a valid a BIC (Bank Identification Code) or SWIFT code`, 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.isIP = isIP;
4
+ exports.isIPRange = isIPRange;
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 is an IP
5
10
  * @validator isIP
6
11
  */
7
- export function isIP(version, options) {
8
- return validator('isIP', (input, context, _this) => {
12
+ function isIP(version, options) {
13
+ return (0, index_js_1.validator)('isIP', (input, context, _this) => {
9
14
  if (input != null &&
10
15
  typeof input === 'string' &&
11
16
  validatorJS.isIP(input, version)) {
@@ -18,8 +23,8 @@ export function isIP(version, options) {
18
23
  * Validates if value is an IP
19
24
  * @validator isIPRange
20
25
  */
21
- export function isIPRange(version, options) {
22
- return validator('isIPRange', (input, context, _this) => {
26
+ function isIPRange(version, options) {
27
+ return (0, index_js_1.validator)('isIPRange', (input, context, _this) => {
23
28
  if (input != null &&
24
29
  typeof input === 'string' &&
25
30
  validatorJS.isIPRange(input, version)) {
@@ -1,15 +1,19 @@
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.isISSN = isISSN;
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 ISSN
5
9
  * @validator isISSN
6
10
  */
7
- export function isISSN(options) {
11
+ function isISSN(options) {
8
12
  const opts = {
9
13
  // eslint-disable-next-line camelcase
10
14
  case_sensitive: options?.caseSensitive,
11
15
  };
12
- return validator('isISSN', (input, context, _this) => {
16
+ return (0, index_js_1.validator)('isISSN', (input, context, _this) => {
13
17
  if (typeof input === 'string' && validatorJS.isISSN(input, opts)) {
14
18
  return input;
15
19
  }