valgen 5.6.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 (161) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/cjs/core/index.js +7 -20
  3. package/cjs/factories.js +2 -15
  4. package/cjs/index.js +4 -29
  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/esm/constants.js +5 -2
  33. package/esm/core/constants.js +5 -2
  34. package/esm/core/context.js +9 -5
  35. package/esm/core/index.js +9 -6
  36. package/esm/core/types.js +2 -1
  37. package/esm/core/utilities.js +10 -6
  38. package/esm/core/validation-error.js +5 -1
  39. package/esm/core/validator.js +18 -14
  40. package/esm/factories.js +4 -1
  41. package/esm/helpers/object.utils.js +6 -2
  42. package/esm/helpers/omit-undefined.js +4 -1
  43. package/esm/helpers/string.utils.js +4 -1
  44. package/esm/index.js +67 -4
  45. package/esm/rules/format-rules/is-alpha.js +11 -6
  46. package/esm/rules/format-rules/is-ascii.js +8 -4
  47. package/esm/rules/format-rules/is-base64.js +8 -4
  48. package/esm/rules/format-rules/is-btc-address.js +8 -4
  49. package/esm/rules/format-rules/is-credit-card.js +8 -4
  50. package/esm/rules/format-rules/is-decimal.js +8 -4
  51. package/esm/rules/format-rules/is-ean.js +8 -4
  52. package/esm/rules/format-rules/is-email.js +8 -4
  53. package/esm/rules/format-rules/is-eth-address.js +8 -4
  54. package/esm/rules/format-rules/is-fqdn.js +8 -4
  55. package/esm/rules/format-rules/is-hash.js +8 -4
  56. package/esm/rules/format-rules/is-hex-color.js +8 -4
  57. package/esm/rules/format-rules/is-hex.js +8 -4
  58. package/esm/rules/format-rules/is-iban.js +11 -6
  59. package/esm/rules/format-rules/is-ip.js +11 -6
  60. package/esm/rules/format-rules/is-issn.js +8 -4
  61. package/esm/rules/format-rules/is-jwt.js +8 -4
  62. package/esm/rules/format-rules/is-lowercase.js +11 -6
  63. package/esm/rules/format-rules/is-mac-address.js +8 -4
  64. package/esm/rules/format-rules/is-mobile-phone.js +8 -4
  65. package/esm/rules/format-rules/is-object-id.js +9 -5
  66. package/esm/rules/format-rules/is-passport-number.js +8 -4
  67. package/esm/rules/format-rules/is-port.js +8 -4
  68. package/esm/rules/format-rules/is-url.js +8 -4
  69. package/esm/rules/format-rules/is-uuid.js +8 -4
  70. package/esm/rules/format-rules/is-vat-number.js +8 -4
  71. package/esm/rules/format-rules/matches.js +6 -3
  72. package/esm/rules/index.js +53 -50
  73. package/esm/rules/logical-rules/is-defined.js +6 -3
  74. package/esm/rules/logical-rules/is-empty.js +9 -5
  75. package/esm/rules/logical-rules/range.js +29 -19
  76. package/esm/rules/type-rules/is-any.js +6 -2
  77. package/esm/rules/type-rules/is-array.js +6 -3
  78. package/esm/rules/type-rules/is-bigint.js +6 -3
  79. package/esm/rules/type-rules/is-boolean.js +6 -3
  80. package/esm/rules/type-rules/is-date.js +14 -10
  81. package/esm/rules/type-rules/is-enum.js +6 -3
  82. package/esm/rules/type-rules/is-integer.js +6 -3
  83. package/esm/rules/type-rules/is-null.js +15 -9
  84. package/esm/rules/type-rules/is-number.js +6 -3
  85. package/esm/rules/type-rules/is-object.js +14 -11
  86. package/esm/rules/type-rules/is-record.js +6 -3
  87. package/esm/rules/type-rules/is-string.js +22 -13
  88. package/esm/rules/type-rules/is-tuple.js +6 -3
  89. package/esm/rules/type-rules/is-undefined.js +6 -3
  90. package/esm/rules/utility-rules/exists.js +6 -3
  91. package/esm/rules/utility-rules/get-length.js +6 -3
  92. package/esm/rules/utility-rules/optional.js +6 -3
  93. package/esm/rules/utility-rules/pipe.js +9 -5
  94. package/esm/rules/utility-rules/required.js +6 -3
  95. package/esm/rules/utility-rules/union.js +6 -3
  96. package/package.json +16 -16
  97. package/cjs/package.json +0 -3
  98. /package/{typings → types}/constants.d.ts +0 -0
  99. /package/{typings → types}/core/constants.d.ts +0 -0
  100. /package/{typings → types}/core/context.d.ts +0 -0
  101. /package/{typings → types}/core/index.d.ts +0 -0
  102. /package/{typings → types}/core/types.d.ts +0 -0
  103. /package/{typings → types}/core/utilities.d.ts +0 -0
  104. /package/{typings → types}/core/validation-error.d.ts +0 -0
  105. /package/{typings → types}/core/validator.d.ts +0 -0
  106. /package/{typings → types}/factories.d.ts +0 -0
  107. /package/{typings → types}/helpers/object.utils.d.ts +0 -0
  108. /package/{typings → types}/helpers/omit-undefined.d.ts +0 -0
  109. /package/{typings → types}/helpers/string.utils.d.ts +0 -0
  110. /package/{typings → types}/index.d.ts +0 -0
  111. /package/{typings → types}/rules/format-rules/is-alpha.d.ts +0 -0
  112. /package/{typings → types}/rules/format-rules/is-ascii.d.ts +0 -0
  113. /package/{typings → types}/rules/format-rules/is-base64.d.ts +0 -0
  114. /package/{typings → types}/rules/format-rules/is-btc-address.d.ts +0 -0
  115. /package/{typings → types}/rules/format-rules/is-credit-card.d.ts +0 -0
  116. /package/{typings → types}/rules/format-rules/is-decimal.d.ts +0 -0
  117. /package/{typings → types}/rules/format-rules/is-ean.d.ts +0 -0
  118. /package/{typings → types}/rules/format-rules/is-email.d.ts +0 -0
  119. /package/{typings → types}/rules/format-rules/is-eth-address.d.ts +0 -0
  120. /package/{typings → types}/rules/format-rules/is-fqdn.d.ts +0 -0
  121. /package/{typings → types}/rules/format-rules/is-hash.d.ts +0 -0
  122. /package/{typings → types}/rules/format-rules/is-hex-color.d.ts +0 -0
  123. /package/{typings → types}/rules/format-rules/is-hex.d.ts +0 -0
  124. /package/{typings → types}/rules/format-rules/is-iban.d.ts +0 -0
  125. /package/{typings → types}/rules/format-rules/is-ip.d.ts +0 -0
  126. /package/{typings → types}/rules/format-rules/is-issn.d.ts +0 -0
  127. /package/{typings → types}/rules/format-rules/is-jwt.d.ts +0 -0
  128. /package/{typings → types}/rules/format-rules/is-lowercase.d.ts +0 -0
  129. /package/{typings → types}/rules/format-rules/is-mac-address.d.ts +0 -0
  130. /package/{typings → types}/rules/format-rules/is-mobile-phone.d.ts +0 -0
  131. /package/{typings → types}/rules/format-rules/is-object-id.d.ts +0 -0
  132. /package/{typings → types}/rules/format-rules/is-passport-number.d.ts +0 -0
  133. /package/{typings → types}/rules/format-rules/is-port.d.ts +0 -0
  134. /package/{typings → types}/rules/format-rules/is-url.d.ts +0 -0
  135. /package/{typings → types}/rules/format-rules/is-uuid.d.ts +0 -0
  136. /package/{typings → types}/rules/format-rules/is-vat-number.d.ts +0 -0
  137. /package/{typings → types}/rules/format-rules/matches.d.ts +0 -0
  138. /package/{typings → types}/rules/index.d.ts +0 -0
  139. /package/{typings → types}/rules/logical-rules/is-defined.d.ts +0 -0
  140. /package/{typings → types}/rules/logical-rules/is-empty.d.ts +0 -0
  141. /package/{typings → types}/rules/logical-rules/range.d.ts +0 -0
  142. /package/{typings → types}/rules/type-rules/is-any.d.ts +0 -0
  143. /package/{typings → types}/rules/type-rules/is-array.d.ts +0 -0
  144. /package/{typings → types}/rules/type-rules/is-bigint.d.ts +0 -0
  145. /package/{typings → types}/rules/type-rules/is-boolean.d.ts +0 -0
  146. /package/{typings → types}/rules/type-rules/is-date.d.ts +0 -0
  147. /package/{typings → types}/rules/type-rules/is-enum.d.ts +0 -0
  148. /package/{typings → types}/rules/type-rules/is-integer.d.ts +0 -0
  149. /package/{typings → types}/rules/type-rules/is-null.d.ts +0 -0
  150. /package/{typings → types}/rules/type-rules/is-number.d.ts +0 -0
  151. /package/{typings → types}/rules/type-rules/is-object.d.ts +0 -0
  152. /package/{typings → types}/rules/type-rules/is-record.d.ts +0 -0
  153. /package/{typings → types}/rules/type-rules/is-string.d.ts +0 -0
  154. /package/{typings → types}/rules/type-rules/is-tuple.d.ts +0 -0
  155. /package/{typings → types}/rules/type-rules/is-undefined.d.ts +0 -0
  156. /package/{typings → types}/rules/utility-rules/exists.d.ts +0 -0
  157. /package/{typings → types}/rules/utility-rules/get-length.d.ts +0 -0
  158. /package/{typings → types}/rules/utility-rules/optional.d.ts +0 -0
  159. /package/{typings → types}/rules/utility-rules/pipe.d.ts +0 -0
  160. /package/{typings → types}/rules/utility-rules/required.d.ts +0 -0
  161. /package/{typings → types}/rules/utility-rules/union.d.ts +0 -0
@@ -1,10 +1,16 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNull = isNull;
4
+ exports.isNotNull = isNotNull;
5
+ exports.isNullish = isNullish;
6
+ exports.isNotNullish = isNotNullish;
7
+ const index_js_1 = require("../../core/index.js");
2
8
  /**
3
9
  * Validates if value is "null".
4
10
  * @validator isNull
5
11
  */
6
- export function isNull(options) {
7
- return validator('isNull', (input, context, _this) => {
12
+ function isNull(options) {
13
+ return (0, index_js_1.validator)('isNull', (input, context, _this) => {
8
14
  if (input === null)
9
15
  return input;
10
16
  context.fail(_this, `{{label}} is not null`, input);
@@ -14,8 +20,8 @@ export function isNull(options) {
14
20
  * Validates if value is not "null".
15
21
  * @validator isNotNull
16
22
  */
17
- export function isNotNull(options) {
18
- return validator('isNotNull', (input, context, _this) => {
23
+ function isNotNull(options) {
24
+ return (0, index_js_1.validator)('isNotNull', (input, context, _this) => {
19
25
  if (input !== null)
20
26
  return input;
21
27
  context.fail(_this, `{{label}} is null`, input);
@@ -25,8 +31,8 @@ export function isNotNull(options) {
25
31
  * Validates if value is "null" or "undefined".
26
32
  * @validator isNullish
27
33
  */
28
- export function isNullish(options) {
29
- return validator('isNullish', (input, context, _this) => {
34
+ function isNullish(options) {
35
+ return (0, index_js_1.validator)('isNullish', (input, context, _this) => {
30
36
  if (input == null)
31
37
  return input;
32
38
  context.fail(_this, `{{label}} is not nullish`, input);
@@ -36,8 +42,8 @@ export function isNullish(options) {
36
42
  * Validates if value is not "null" nor "undefined".
37
43
  * @validator isNotNullish
38
44
  */
39
- export function isNotNullish(options) {
40
- return validator('isNotNullish', (input, context, _this) => {
45
+ function isNotNullish(options) {
46
+ return (0, index_js_1.validator)('isNotNullish', (input, context, _this) => {
41
47
  if (input != null)
42
48
  return input;
43
49
  if (input === null)
@@ -1,11 +1,14 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNumber = isNumber;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates if value is "number".
4
7
  * Converts input value to number if coerce option is set to 'true'.
5
8
  * @validator isNumber
6
9
  */
7
- export function isNumber(options) {
8
- return validator('isNumber', (input, context, _this) => {
10
+ function isNumber(options) {
11
+ return (0, index_js_1.validator)('isNumber', (input, context, _this) => {
9
12
  const coerce = options?.coerce || context.coerce;
10
13
  let output = input;
11
14
  if (output != null && typeof output !== 'number' && coerce) {
@@ -1,11 +1,14 @@
1
- import { postValidation, preValidation } from '../../constants.js';
2
- import { isValidator, validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = isObject;
4
+ const constants_js_1 = require("../../constants.js");
5
+ const index_js_1 = require("../../core/index.js");
3
6
  /**
4
7
  * Validates object according to schema
5
8
  * Converts properties according to schema rules if coerce option is set to 'true'.
6
9
  * @validator isObject
7
10
  */
8
- export function isObject(schema, options) {
11
+ function isObject(schema, options) {
9
12
  const ctor = options?.ctor;
10
13
  const ctorName = options?.name || ctor?.name;
11
14
  const additionalFields = options?.additionalFields ?? !schema;
@@ -19,13 +22,13 @@ export function isObject(schema, options) {
19
22
  const n = schema[k];
20
23
  const key = caseInSensitive ? k.toLowerCase() : k;
21
24
  if (Array.isArray(n)) {
22
- if (!isValidator(n[0])) {
25
+ if (!(0, index_js_1.isValidator)(n[0])) {
23
26
  throw new TypeError(`Invalid tuple definition in validation schema (${k})`);
24
27
  }
25
28
  propertyRules[key] = n[0];
26
29
  propertyOptions[key] = { as: k, ...n[1] };
27
30
  }
28
- else if (isValidator(n)) {
31
+ else if ((0, index_js_1.isValidator)(n)) {
29
32
  propertyRules[key] = n;
30
33
  propertyOptions[key] = { as: k };
31
34
  }
@@ -33,10 +36,10 @@ export function isObject(schema, options) {
33
36
  throw new TypeError(`Invalid definition in validation schema (${k})`);
34
37
  }
35
38
  }
36
- const _rule = validator('isObject', (input, context, _this) => {
39
+ const _rule = (0, index_js_1.validator)('isObject', (input, context, _this) => {
37
40
  let output = input;
38
- if (ctor && ctor[preValidation]) {
39
- output = ctor[preValidation](output, context, _this);
41
+ if (ctor && ctor[constants_js_1.preValidation]) {
42
+ output = ctor[constants_js_1.preValidation](output, context, _this);
40
43
  }
41
44
  const coerce = options?.coerce || context.coerce;
42
45
  if (typeof output === 'string' && coerce)
@@ -73,7 +76,7 @@ export function isObject(schema, options) {
73
76
  v = output[inputKey];
74
77
  _propRule =
75
78
  propertyRules[schemaKey] ||
76
- (isValidator(additionalFields) ? additionalFields : undefined);
79
+ ((0, index_js_1.isValidator)(additionalFields) ? additionalFields : undefined);
77
80
  if (_propRule) {
78
81
  if (processedSchemaKeys[schemaKey])
79
82
  continue;
@@ -101,8 +104,8 @@ export function isObject(schema, options) {
101
104
  }
102
105
  if (context.errors.length)
103
106
  return undefined;
104
- if (ctor && ctor[postValidation]) {
105
- ctor[postValidation](out, context, _this);
107
+ if (ctor && ctor[constants_js_1.postValidation]) {
108
+ ctor[constants_js_1.postValidation](out, context, _this);
106
109
  return out;
107
110
  }
108
111
  return out;
@@ -1,11 +1,14 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRecord = isRecord;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates record object according to given "key" and "value" rules
4
7
  * Converts properties according to rules if coerce option is set to 'true'.
5
8
  * @validator isRecord
6
9
  */
7
- export function isRecord(keyRule, valueRule, options) {
8
- return validator('isRecord', (input, context, _this) => {
10
+ function isRecord(keyRule, valueRule, options) {
11
+ return (0, index_js_1.validator)('isRecord', (input, context, _this) => {
9
12
  if (!(input && typeof input === 'object')) {
10
13
  context.fail(_this, `{{label}} must be an object`, input);
11
14
  return;
@@ -1,11 +1,18 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trimStart = exports.trimEnd = void 0;
4
+ exports.isString = isString;
5
+ exports.stringReplace = stringReplace;
6
+ exports.stringSplit = stringSplit;
7
+ exports.trim = trim;
8
+ const index_js_1 = require("../../core/index.js");
2
9
  /**
3
10
  * Validates if value is "string".
4
11
  * Converts input value to string if coerce option is set to 'true'.
5
12
  * @validator isString
6
13
  */
7
- export function isString(options) {
8
- return validator('isString', (input, context, _this) => {
14
+ function isString(options) {
15
+ return (0, index_js_1.validator)('isString', (input, context, _this) => {
9
16
  const coerce = options?.coerce || context.coerce;
10
17
  let output = input;
11
18
  if (output != null && typeof output !== 'string' && coerce) {
@@ -23,15 +30,15 @@ export function isString(options) {
23
30
  context.fail(_this, `"{{value}}" is not a string`, input);
24
31
  }, options);
25
32
  }
26
- export function stringReplace(searchValue, replacer) {
27
- return validator('stringReplace', (input) => {
33
+ function stringReplace(searchValue, replacer) {
34
+ return (0, index_js_1.validator)('stringReplace', (input) => {
28
35
  if (input == null)
29
36
  return input;
30
37
  return String(input).replace(searchValue, replacer);
31
38
  });
32
39
  }
33
- export function stringSplit(splitter, limit) {
34
- return validator('stringSplit', (input) => {
40
+ function stringSplit(splitter, limit) {
41
+ return (0, index_js_1.validator)('stringSplit', (input) => {
35
42
  if (input == null)
36
43
  return input;
37
44
  return String(input).split(splitter, limit);
@@ -41,8 +48,8 @@ export function stringSplit(splitter, limit) {
41
48
  * Removes whitespace from both ends of a string
42
49
  * @validator trim
43
50
  */
44
- export function trim() {
45
- return validator('trim', (input) => {
51
+ function trim() {
52
+ return (0, index_js_1.validator)('trim', (input) => {
46
53
  if (input == null)
47
54
  return input;
48
55
  return String(input).trim();
@@ -53,8 +60,9 @@ export function trim() {
53
60
  * Removes whitespace from the end of a string
54
61
  * @validator trimEnd
55
62
  */
56
- export const trimEnd = () => trimEndRule;
57
- const trimEndRule = validator('trimEnd', (input) => {
63
+ const trimEnd = () => trimEndRule;
64
+ exports.trimEnd = trimEnd;
65
+ const trimEndRule = (0, index_js_1.validator)('trimEnd', (input) => {
58
66
  if (input == null)
59
67
  return input;
60
68
  return String(input).trimEnd();
@@ -64,8 +72,9 @@ const trimEndRule = validator('trimEnd', (input) => {
64
72
  * Removes whitespace from the beginning of a string
65
73
  * @validator trimStart
66
74
  */
67
- export const trimStart = () => trimStartRule;
68
- const trimStartRule = validator('trimStart', (input) => {
75
+ const trimStart = () => trimStartRule;
76
+ exports.trimStart = trimStart;
77
+ const trimStartRule = (0, index_js_1.validator)('trimStart', (input) => {
69
78
  if (input == null)
70
79
  return input;
71
80
  return String(input).trimStart();
@@ -1,6 +1,9 @@
1
- import { validator, } from '../../core/index.js';
2
- export function isTuple(items, options) {
3
- return validator('isTuple', (input, context, _this) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTuple = isTuple;
4
+ const index_js_1 = require("../../core/index.js");
5
+ function isTuple(items, options) {
6
+ return (0, index_js_1.validator)('isTuple', (input, context, _this) => {
4
7
  const coerce = options?.coerce || context.coerce;
5
8
  let output = input;
6
9
  if (output != null && coerce && !Array.isArray(output))
@@ -1,10 +1,13 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUndefined = isUndefined;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates if value is "undefined"
4
7
  * @validator isUndefined
5
8
  */
6
- export function isUndefined(options) {
7
- return validator('isUndefined', (input, context, _this) => {
9
+ function isUndefined(options) {
10
+ return (0, index_js_1.validator)('isUndefined', (input, context, _this) => {
8
11
  if (options?.coerce || context.coerce)
9
12
  return undefined;
10
13
  if (input === undefined)
@@ -1,10 +1,13 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exists = exists;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Validates if property exists
4
7
  * @validator exists
5
8
  */
6
- export function exists(options) {
7
- return validator('exists', (input, context, _this) => {
9
+ function exists(options) {
10
+ return (0, index_js_1.validator)('exists', (input, context, _this) => {
8
11
  if (input !== undefined ||
9
12
  (context.scope &&
10
13
  Object.getOwnPropertyDescriptor(context.scope, input))) {
@@ -1,10 +1,13 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLength = getLength;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Returns length of an Array, String, ArrayBuffer, Buffer or any object with the "length" property.
4
7
  * @validator getLength
5
8
  */
6
- export function getLength() {
7
- return validator('getLength', (input, context, _this) => {
9
+ function getLength() {
10
+ return (0, index_js_1.validator)('getLength', (input, context, _this) => {
8
11
  if (typeof input === 'string')
9
12
  return input.length;
10
13
  if (Array.isArray(input))
@@ -1,10 +1,13 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optional = optional;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Makes sub-rule optional
4
7
  * @validator optional
5
8
  */
6
- export function optional(nested, options) {
7
- return validator('optional', (input, context) => {
9
+ function optional(nested, options) {
10
+ return (0, index_js_1.validator)('optional', (input, context) => {
8
11
  if (input == null)
9
12
  return input;
10
13
  return nested(input, context);
@@ -1,12 +1,16 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pipe = pipe;
4
+ exports.allOf = allOf;
5
+ const index_js_1 = require("../../core/index.js");
2
6
  /**
3
7
  *
4
8
  * @validator pipe
5
9
  */
6
- export function pipe(rules, options) {
10
+ function pipe(rules, options) {
7
11
  const l = rules.length;
8
12
  const returnIndex = options?.returnIndex;
9
- return validator('pipe', (input, context) => {
13
+ return (0, index_js_1.validator)('pipe', (input, context) => {
10
14
  let i;
11
15
  let c;
12
16
  let v = input;
@@ -26,8 +30,8 @@ export function pipe(rules, options) {
26
30
  * Test given value against to all codecs and returns original input
27
31
  * @validator allOf
28
32
  */
29
- export function allOf(rules) {
30
- return validator('allOf', (input, context) => {
33
+ function allOf(rules) {
34
+ return (0, index_js_1.validator)('allOf', (input, context) => {
31
35
  let i;
32
36
  let c;
33
37
  const l = rules.length;
@@ -1,10 +1,13 @@
1
- import { validator, } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.required = required;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  * Makes sub-rule required
4
7
  * @validator required
5
8
  */
6
- export function required(nested, options) {
7
- return validator('required', (input, context, _this) => {
9
+ function required(nested, options) {
10
+ return (0, index_js_1.validator)('required', (input, context, _this) => {
8
11
  if (input == null) {
9
12
  context.fail(_this, `{{label}} is required`, input);
10
13
  return;
@@ -1,10 +1,13 @@
1
- import { validator } from '../../core/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.union = union;
4
+ const index_js_1 = require("../../core/index.js");
2
5
  /**
3
6
  *
4
7
  */
5
- export function union(codecs) {
8
+ function union(codecs) {
6
9
  const l = codecs.length;
7
- return validator('union', (input, context, _this) => {
10
+ return (0, index_js_1.validator)('union', (input, context, _this) => {
8
11
  let i;
9
12
  let c;
10
13
  let v;
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "valgen",
3
3
  "description": "Fast runtime type validator, converter and io (encoding/decoding) library",
4
- "version": "5.6.0",
4
+ "version": "5.7.0",
5
5
  "author": "Panates",
6
- "contributors": [
7
- "Eray Hanoglu <e.hanoglu@panates.com>"
8
- ],
9
6
  "license": "MIT",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/panates/valgen.git"
13
- },
14
7
  "dependencies": {
15
8
  "@types/validator": "^13.12.0",
16
9
  "date-fns": "^3.6.0",
17
- "ts-gems": "^3.4.0",
10
+ "ts-gems": "^3.5.0",
18
11
  "validator": "^13.12.0"
19
12
  },
20
- "type": "module",
21
- "types": "typings/index.d.ts",
13
+ "main": "./cjs/index.js",
14
+ "module": "./esm/index.js",
15
+ "types": "./types/index.d.ts",
22
16
  "exports": {
23
17
  ".": {
24
18
  "require": "./cjs/index.js",
25
- "default": "./esm/index.js"
26
- },
27
- "./cjs": "./cjs/index.js",
28
- "./esm": "./esm/index.js"
19
+ "import": "./esm/index.js",
20
+ "types": "./types/index.d.ts"
21
+ }
22
+ },
23
+ "contributors": [
24
+ "Eray Hanoglu <e.hanoglu@panates.com>"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/panates/valgen.git"
29
29
  },
30
30
  "engines": {
31
31
  "node": ">= 16.0"
@@ -33,7 +33,7 @@
33
33
  "files": [
34
34
  "cjs/",
35
35
  "esm/",
36
- "typings/",
36
+ "types/",
37
37
  "LICENSE",
38
38
  "README.md",
39
39
  "CHANGELOG.md"
package/cjs/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes