umt 2.18.0 → 2.20.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 (168) hide show
  1. package/module/Validate/any/core.d.ts +21 -0
  2. package/module/Validate/any/core.js +19 -0
  3. package/module/Validate/any/core.js.map +1 -0
  4. package/module/Validate/any/index.d.ts +1 -0
  5. package/module/Validate/any/index.js +2 -0
  6. package/module/Validate/any/index.js.map +1 -0
  7. package/module/Validate/array/arrayOf.d.ts +14 -0
  8. package/module/Validate/array/arrayOf.js +36 -0
  9. package/module/Validate/array/arrayOf.js.map +1 -0
  10. package/module/Validate/array/index.d.ts +1 -0
  11. package/module/Validate/array/index.js +1 -0
  12. package/module/Validate/array/index.js.map +1 -1
  13. package/module/Validate/bigint/core.d.ts +24 -0
  14. package/module/Validate/bigint/core.js +37 -0
  15. package/module/Validate/bigint/core.js.map +1 -0
  16. package/module/Validate/bigint/index.d.ts +1 -0
  17. package/module/Validate/bigint/index.js +2 -0
  18. package/module/Validate/bigint/index.js.map +1 -0
  19. package/module/Validate/date/core.d.ts +14 -0
  20. package/module/Validate/date/core.js +29 -0
  21. package/module/Validate/date/core.js.map +1 -0
  22. package/module/Validate/date/index.d.ts +1 -0
  23. package/module/Validate/date/index.js +2 -0
  24. package/module/Validate/date/index.js.map +1 -0
  25. package/module/Validate/file/core.d.ts +13 -0
  26. package/module/Validate/file/core.js +32 -0
  27. package/module/Validate/file/core.js.map +1 -0
  28. package/module/Validate/file/index.d.ts +1 -0
  29. package/module/Validate/file/index.js +2 -0
  30. package/module/Validate/file/index.js.map +1 -0
  31. package/module/Validate/function/core.d.ts +75 -0
  32. package/module/Validate/function/core.js +66 -0
  33. package/module/Validate/function/core.js.map +1 -0
  34. package/module/Validate/function/index.d.ts +1 -0
  35. package/module/Validate/function/index.js +2 -0
  36. package/module/Validate/function/index.js.map +1 -0
  37. package/module/Validate/index.d.ts +11 -0
  38. package/module/Validate/index.js +11 -0
  39. package/module/Validate/index.js.map +1 -1
  40. package/module/Validate/instanceof/core.d.ts +19 -0
  41. package/module/Validate/instanceof/core.js +32 -0
  42. package/module/Validate/instanceof/core.js.map +1 -0
  43. package/module/Validate/instanceof/index.d.ts +1 -0
  44. package/module/Validate/instanceof/index.js +2 -0
  45. package/module/Validate/instanceof/index.js.map +1 -0
  46. package/module/Validate/map/core.d.ts +24 -0
  47. package/module/Validate/map/core.js +57 -0
  48. package/module/Validate/map/core.js.map +1 -0
  49. package/module/Validate/map/index.d.ts +1 -0
  50. package/module/Validate/map/index.js +2 -0
  51. package/module/Validate/map/index.js.map +1 -0
  52. package/module/Validate/never/core.d.ts +22 -0
  53. package/module/Validate/never/core.js +23 -0
  54. package/module/Validate/never/core.js.map +1 -0
  55. package/module/Validate/never/index.d.ts +1 -0
  56. package/module/Validate/never/index.js +2 -0
  57. package/module/Validate/never/index.js.map +1 -0
  58. package/module/Validate/object/core.d.ts +22 -4
  59. package/module/Validate/object/core.js +5 -3
  60. package/module/Validate/object/core.js.map +1 -1
  61. package/module/Validate/object/index.d.ts +4 -0
  62. package/module/Validate/object/index.js +4 -0
  63. package/module/Validate/object/index.js.map +1 -1
  64. package/module/Validate/object/nullable.d.ts +12 -2
  65. package/module/Validate/object/nullable.js +2 -2
  66. package/module/Validate/object/nullable.js.map +1 -1
  67. package/module/Validate/object/omit.d.ts +22 -0
  68. package/module/Validate/object/omit.js +33 -0
  69. package/module/Validate/object/omit.js.map +1 -0
  70. package/module/Validate/object/optional.d.ts +31 -3
  71. package/module/Validate/object/optional.js +7 -5
  72. package/module/Validate/object/optional.js.map +1 -1
  73. package/module/Validate/object/partial.d.ts +25 -0
  74. package/module/Validate/object/partial.js +29 -0
  75. package/module/Validate/object/partial.js.map +1 -0
  76. package/module/Validate/object/pick.d.ts +21 -0
  77. package/module/Validate/object/pick.js +29 -0
  78. package/module/Validate/object/pick.js.map +1 -0
  79. package/module/Validate/object/required.d.ts +22 -0
  80. package/module/Validate/object/required.js +30 -0
  81. package/module/Validate/object/required.js.map +1 -0
  82. package/module/Validate/set/core.d.ts +24 -0
  83. package/module/Validate/set/core.js +47 -0
  84. package/module/Validate/set/core.js.map +1 -0
  85. package/module/Validate/set/index.d.ts +1 -0
  86. package/module/Validate/set/index.js +2 -0
  87. package/module/Validate/set/index.js.map +1 -0
  88. package/module/Validate/templateLiteral/core.d.ts +55 -0
  89. package/module/Validate/templateLiteral/core.js +68 -0
  90. package/module/Validate/templateLiteral/core.js.map +1 -0
  91. package/module/Validate/templateLiteral/index.d.ts +1 -0
  92. package/module/Validate/templateLiteral/index.js +2 -0
  93. package/module/Validate/templateLiteral/index.js.map +1 -0
  94. package/module/Validate/type.d.ts +8 -6
  95. package/module/Validate/unknown/core.d.ts +21 -0
  96. package/module/Validate/unknown/core.js +16 -0
  97. package/module/Validate/unknown/core.js.map +1 -0
  98. package/module/Validate/unknown/index.d.ts +1 -0
  99. package/module/Validate/unknown/index.js +2 -0
  100. package/module/Validate/unknown/index.js.map +1 -0
  101. package/module/es5/Validate/any/core.d.ts +21 -0
  102. package/module/es5/Validate/any/core.js +36 -0
  103. package/module/es5/Validate/any/index.d.ts +1 -0
  104. package/module/es5/Validate/any/index.js +16 -0
  105. package/module/es5/Validate/array/arrayOf.d.ts +14 -0
  106. package/module/es5/Validate/array/arrayOf.js +53 -0
  107. package/module/es5/Validate/array/index.d.ts +1 -0
  108. package/module/es5/Validate/array/index.js +11 -0
  109. package/module/es5/Validate/bigint/core.d.ts +24 -0
  110. package/module/es5/Validate/bigint/core.js +65 -0
  111. package/module/es5/Validate/bigint/index.d.ts +1 -0
  112. package/module/es5/Validate/bigint/index.js +16 -0
  113. package/module/es5/Validate/date/core.d.ts +14 -0
  114. package/module/es5/Validate/date/core.js +35 -0
  115. package/module/es5/Validate/date/index.d.ts +1 -0
  116. package/module/es5/Validate/date/index.js +16 -0
  117. package/module/es5/Validate/file/core.d.ts +13 -0
  118. package/module/es5/Validate/file/core.js +39 -0
  119. package/module/es5/Validate/file/index.d.ts +1 -0
  120. package/module/es5/Validate/file/index.js +16 -0
  121. package/module/es5/Validate/function/core.d.ts +75 -0
  122. package/module/es5/Validate/function/core.js +125 -0
  123. package/module/es5/Validate/function/index.d.ts +1 -0
  124. package/module/es5/Validate/function/index.js +16 -0
  125. package/module/es5/Validate/index.d.ts +11 -0
  126. package/module/es5/Validate/index.js +121 -0
  127. package/module/es5/Validate/instanceof/core.d.ts +19 -0
  128. package/module/es5/Validate/instanceof/core.js +40 -0
  129. package/module/es5/Validate/instanceof/index.d.ts +1 -0
  130. package/module/es5/Validate/instanceof/index.js +16 -0
  131. package/module/es5/Validate/map/core.d.ts +24 -0
  132. package/module/es5/Validate/map/core.js +81 -0
  133. package/module/es5/Validate/map/index.d.ts +1 -0
  134. package/module/es5/Validate/map/index.js +16 -0
  135. package/module/es5/Validate/never/core.d.ts +22 -0
  136. package/module/es5/Validate/never/core.js +35 -0
  137. package/module/es5/Validate/never/index.d.ts +1 -0
  138. package/module/es5/Validate/never/index.js +16 -0
  139. package/module/es5/Validate/object/core.d.ts +22 -4
  140. package/module/es5/Validate/object/core.js +14 -2
  141. package/module/es5/Validate/object/index.d.ts +4 -0
  142. package/module/es5/Validate/object/index.js +44 -0
  143. package/module/es5/Validate/object/nullable.d.ts +12 -2
  144. package/module/es5/Validate/object/nullable.js +2 -2
  145. package/module/es5/Validate/object/omit.d.ts +22 -0
  146. package/module/es5/Validate/object/omit.js +39 -0
  147. package/module/es5/Validate/object/optional.d.ts +31 -3
  148. package/module/es5/Validate/object/optional.js +12 -3
  149. package/module/es5/Validate/object/partial.d.ts +25 -0
  150. package/module/es5/Validate/object/partial.js +33 -0
  151. package/module/es5/Validate/object/pick.d.ts +21 -0
  152. package/module/es5/Validate/object/pick.js +45 -0
  153. package/module/es5/Validate/object/required.d.ts +22 -0
  154. package/module/es5/Validate/object/required.js +33 -0
  155. package/module/es5/Validate/set/core.d.ts +24 -0
  156. package/module/es5/Validate/set/core.js +65 -0
  157. package/module/es5/Validate/set/index.d.ts +1 -0
  158. package/module/es5/Validate/set/index.js +16 -0
  159. package/module/es5/Validate/templateLiteral/core.d.ts +55 -0
  160. package/module/es5/Validate/templateLiteral/core.js +114 -0
  161. package/module/es5/Validate/templateLiteral/index.d.ts +1 -0
  162. package/module/es5/Validate/templateLiteral/index.js +16 -0
  163. package/module/es5/Validate/type.d.ts +8 -6
  164. package/module/es5/Validate/unknown/core.d.ts +21 -0
  165. package/module/es5/Validate/unknown/core.js +34 -0
  166. package/module/es5/Validate/unknown/index.d.ts +1 -0
  167. package/module/es5/Validate/unknown/index.js +16 -0
  168. package/package.json +11 -11
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.map = void 0;
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ /**
15
+ * Map validation core module
16
+ * Provides validation for `Map` instances. The validator can optionally
17
+ * delegate to per-entry validators for keys and values, mirroring how
18
+ * `arrayOf()` validates each element of an array.
19
+ */
20
+
21
+ /**
22
+ * Creates a Map validator. The validator can optionally accept per-entry key
23
+ * and value validators that are applied to every entry of the map. When the
24
+ * value-side validator is provided, the entry validators short-circuit on the
25
+ * first failure and surface the failing message, mirroring `arrayOf()`.
26
+ * @template KV - Validator for the map key
27
+ * @template VV - Validator for the map value
28
+ * @param {KV} [keyValidator] - Validator applied to every key
29
+ * @param {VV} [valueValidator] - Validator applied to every value
30
+ * @param {string} [message] - Custom error message for type validation
31
+ * @returns {Function} - Validator function for Map instances
32
+ */
33
+ var map = exports.map = function map(keyValidator, valueValidator, message) {
34
+ return function (value) {
35
+ if (!(value instanceof Map)) {
36
+ return {
37
+ validate: false,
38
+ message: message !== null && message !== void 0 ? message : "",
39
+ type: value
40
+ };
41
+ }
42
+ var _iterator = _createForOfIteratorHelper(value),
43
+ _step;
44
+ try {
45
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
+ var _step$value = _slicedToArray(_step.value, 2),
47
+ entryKey = _step$value[0],
48
+ entryValue = _step$value[1];
49
+ if (keyValidator) {
50
+ var keyResult = keyValidator(entryKey);
51
+ if (!keyResult.validate) {
52
+ return {
53
+ validate: false,
54
+ message: keyResult.message,
55
+ type: value
56
+ };
57
+ }
58
+ }
59
+ if (valueValidator) {
60
+ var valueResult = valueValidator(entryValue);
61
+ if (!valueResult.validate) {
62
+ return {
63
+ validate: false,
64
+ message: valueResult.message,
65
+ type: value
66
+ };
67
+ }
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator.e(err);
72
+ } finally {
73
+ _iterator.f();
74
+ }
75
+ return {
76
+ validate: true,
77
+ message: "",
78
+ type: value
79
+ };
80
+ };
81
+ };
@@ -0,0 +1 @@
1
+ export * from "./core";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _core = require("./core");
7
+ Object.keys(_core).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _core[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _core[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Never validation core module
3
+ * Provides a validator that fails for every input, useful for marking
4
+ * positions in a schema that must never be filled (for example, exhaustive
5
+ * union members that should be unreachable at the type level).
6
+ */
7
+ /**
8
+ * Return type produced by a `never` validator. Exposes the literal `"never"`
9
+ * tag through the `type` field so `ValidateType<"never">` can map it back to
10
+ * the `never` runtime type when consumed by downstream helpers.
11
+ */
12
+ export interface NeverReturnType {
13
+ validate: boolean;
14
+ message: string;
15
+ type: "never";
16
+ }
17
+ /**
18
+ * Creates a validator that always fails
19
+ * @param {string} [message] - Custom error message for validation failure
20
+ * @returns {Function} - Validator that always returns a failing result
21
+ */
22
+ export declare const never: (message?: string) => ((value: any) => NeverReturnType);
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.never = void 0;
7
+ /**
8
+ * Never validation core module
9
+ * Provides a validator that fails for every input, useful for marking
10
+ * positions in a schema that must never be filled (for example, exhaustive
11
+ * union members that should be unreachable at the type level).
12
+ */
13
+
14
+ /**
15
+ * Return type produced by a `never` validator. Exposes the literal `"never"`
16
+ * tag through the `type` field so `ValidateType<"never">` can map it back to
17
+ * the `never` runtime type when consumed by downstream helpers.
18
+ */
19
+
20
+ /**
21
+ * Creates a validator that always fails
22
+ * @param {string} [message] - Custom error message for validation failure
23
+ * @returns {Function} - Validator that always returns a failing result
24
+ */
25
+ // biome-ignore lint/suspicious/noExplicitAny: never() is widened to accept any input from union/intersection
26
+ var never = exports.never = function never(message) {
27
+ // biome-ignore lint/suspicious/noExplicitAny: signature mirrors the public type
28
+ return function (_value) {
29
+ return {
30
+ validate: false,
31
+ message: message !== null && message !== void 0 ? message : "",
32
+ type: "never"
33
+ };
34
+ };
35
+ };
@@ -0,0 +1 @@
1
+ export * from "./core";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _core = require("./core");
7
+ Object.keys(_core).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _core[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _core[key];
14
+ }
15
+ });
16
+ });
@@ -4,13 +4,31 @@
4
4
  */
5
5
  import type { PickPartial } from "../../types/object";
6
6
  import type { OptionalKeys, ValidateCoreReturnType, ValidateType } from "../../Validate/type";
7
+ /**
8
+ * Shape map describing per-property validators consumed by `object()`
9
+ */
10
+ export interface ObjectShape {
11
+ [key: string]: (value: any) => ValidateCoreReturnType<unknown>;
12
+ }
13
+ /**
14
+ * Object validator augmented with the original `shape` map. The shape map is
15
+ * exposed so derived helpers such as `pick()`, `omit()`, `partial()`, and
16
+ * `required()` can compose new object validators from existing ones.
17
+ */
18
+ export type ObjectValidator<T extends ObjectShape, U = {
19
+ [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>;
20
+ }> = ((value: {
21
+ [key in keyof PickPartial<U, OptionalKeys<U>>]: PickPartial<U, OptionalKeys<U>>[key];
22
+ }) => ValidateCoreReturnType<{
23
+ [key in keyof PickPartial<U, OptionalKeys<U>>]: PickPartial<U, OptionalKeys<U>>[key];
24
+ }>) & {
25
+ shape: T;
26
+ };
7
27
  /**
8
28
  * Creates an object validator with property-specific validation rules
9
29
  * @template T - Object type containing validation functions for each property
10
30
  * @param {T} [option] - Object containing validation functions for each property
11
31
  * @param {string} [message] - Custom error message for object type validation
12
- * @returns {Function} - Validator function that checks if the value is an object and validates its properties
32
+ * @returns {ObjectValidator<T>} - Validator function with `.shape` attached so it can compose with `pick()`, `omit()`, `partial()`, and `required()`
13
33
  */
14
- export declare const object: <T extends {
15
- [key: string]: (value: any) => ValidateCoreReturnType<any>;
16
- }, U = { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }>(option?: T, message?: string) => (value: { [key in keyof PickPartial<U, OptionalKeys<U>>]: PickPartial<U, OptionalKeys<U>>[key]; }) => ValidateCoreReturnType<{ [key in keyof PickPartial<U, OptionalKeys<U>>]: PickPartial<U, OptionalKeys<U>>[key]; }>;
34
+ export declare const object: <T extends ObjectShape>(option?: T, message?: string) => ObjectValidator<T>;
@@ -10,17 +10,27 @@ var _isDictionaryObject = require("../../Validate/isDictionaryObject");
10
10
  * Provides validation functionality for objects with type-specific validation rules for each property
11
11
  */
12
12
 
13
+ /**
14
+ * Shape map describing per-property validators consumed by `object()`
15
+ */
16
+
17
+ /**
18
+ * Object validator augmented with the original `shape` map. The shape map is
19
+ * exposed so derived helpers such as `pick()`, `omit()`, `partial()`, and
20
+ * `required()` can compose new object validators from existing ones.
21
+ */
22
+
13
23
  /**
14
24
  * Creates an object validator with property-specific validation rules
15
25
  * @template T - Object type containing validation functions for each property
16
26
  * @param {T} [option] - Object containing validation functions for each property
17
27
  * @param {string} [message] - Custom error message for object type validation
18
- * @returns {Function} - Validator function that checks if the value is an object and validates its properties
28
+ * @returns {ObjectValidator<T>} - Validator function with `.shape` attached so it can compose with `pick()`, `omit()`, `partial()`, and `required()`
19
29
  */
20
30
  var object = exports.object = function object() {
21
31
  var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22
32
  var message = arguments.length > 1 ? arguments[1] : undefined;
23
- return function (value) {
33
+ var validator = function validator(value) {
24
34
  if (!(0, _isDictionaryObject.isDictionaryObject)(value)) {
25
35
  return {
26
36
  validate: false,
@@ -47,4 +57,6 @@ var object = exports.object = function object() {
47
57
  type: value
48
58
  };
49
59
  };
60
+ validator.shape = option;
61
+ return validator;
50
62
  };
@@ -1,5 +1,9 @@
1
1
  export * from "./core";
2
2
  export * from "./intersection";
3
3
  export * from "./nullable";
4
+ export * from "./omit";
4
5
  export * from "./optional";
6
+ export * from "./partial";
7
+ export * from "./pick";
8
+ export * from "./required";
5
9
  export * from "./union";
@@ -36,6 +36,17 @@ Object.keys(_nullable).forEach(function (key) {
36
36
  }
37
37
  });
38
38
  });
39
+ var _omit = require("./omit");
40
+ Object.keys(_omit).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _omit[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _omit[key];
47
+ }
48
+ });
49
+ });
39
50
  var _optional = require("./optional");
40
51
  Object.keys(_optional).forEach(function (key) {
41
52
  if (key === "default" || key === "__esModule") return;
@@ -47,6 +58,39 @@ Object.keys(_optional).forEach(function (key) {
47
58
  }
48
59
  });
49
60
  });
61
+ var _partial = require("./partial");
62
+ Object.keys(_partial).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _partial[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function get() {
68
+ return _partial[key];
69
+ }
70
+ });
71
+ });
72
+ var _pick = require("./pick");
73
+ Object.keys(_pick).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _pick[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function get() {
79
+ return _pick[key];
80
+ }
81
+ });
82
+ });
83
+ var _required = require("./required");
84
+ Object.keys(_required).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _required[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function get() {
90
+ return _required[key];
91
+ }
92
+ });
93
+ });
50
94
  var _union = require("./union");
51
95
  Object.keys(_union).forEach(function (key) {
52
96
  if (key === "default" || key === "__esModule") return;
@@ -1,8 +1,18 @@
1
- import type { ValidateCoreReturnType } from "../../Validate/type";
1
+ interface NullReturn {
2
+ validate: boolean;
3
+ message: string;
4
+ type: "null";
5
+ }
2
6
  /**
3
7
  * Wraps a validator to accept null values
4
8
  * @template T - The type of value the wrapped validator expects
9
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
5
10
  * @param {Function} validator - Validator function to make nullable
6
11
  * @returns {Function} - Validator that passes for null or delegates to the wrapped validator
7
12
  */
8
- export declare const nullable: <T>(validator: (value: T) => ValidateCoreReturnType<T>) => ((value: T | null) => ValidateCoreReturnType<T | null>);
13
+ export declare const nullable: <T, R extends {
14
+ type: unknown;
15
+ message: string;
16
+ validate: boolean;
17
+ }>(validator: (value: T) => R) => ((value: T | null) => R | NullReturn);
18
+ export {};
@@ -7,6 +7,7 @@ exports.nullable = void 0;
7
7
  /**
8
8
  * Wraps a validator to accept null values
9
9
  * @template T - The type of value the wrapped validator expects
10
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
10
11
  * @param {Function} validator - Validator function to make nullable
11
12
  * @returns {Function} - Validator that passes for null or delegates to the wrapped validator
12
13
  */
@@ -19,8 +20,7 @@ var nullable = exports.nullable = function nullable(validator) {
19
20
  type: "null"
20
21
  };
21
22
  }
22
- var result = validator(value);
23
- return result;
23
+ return validator(value);
24
24
  };
25
25
  return nullableValidator;
26
26
  };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Object validation - omit
3
+ * Returns a new object validator that drops the specified keys from the
4
+ * source validator. Mirrors `Omit<T, K>` at the type level so consumers
5
+ * like `union()`, `intersection()`, and `SchemaToInterface` see the
6
+ * narrowed shape.
7
+ *
8
+ * The function is exported as `omit_` because the top-level `Object` module
9
+ * already exposes an `omit` runtime helper.
10
+ */
11
+ import { type ObjectShape, type ObjectValidator } from "./core";
12
+ /**
13
+ * Removes the given keys from an existing object validator and returns a new
14
+ * object validator covering the remaining keys.
15
+ * @template T - Original object shape
16
+ * @template K - Tuple of keys to omit from the original shape
17
+ * @param {ObjectValidator<T>} validator - Source object validator
18
+ * @param {K} keys - Keys to drop from the new validator
19
+ * @param {string} [message] - Custom error message for the omitted validator
20
+ * @returns {ObjectValidator<Omit<T, K[number]>>} - New validator without omitted keys
21
+ */
22
+ export declare const omit_: <T extends ObjectShape, K extends readonly (keyof T)[]>(validator: ObjectValidator<T>, keys: K, message?: string) => ObjectValidator<Omit<T, K[number]>>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.omit_ = void 0;
7
+ var _core = require("./core");
8
+ /**
9
+ * Object validation - omit
10
+ * Returns a new object validator that drops the specified keys from the
11
+ * source validator. Mirrors `Omit<T, K>` at the type level so consumers
12
+ * like `union()`, `intersection()`, and `SchemaToInterface` see the
13
+ * narrowed shape.
14
+ *
15
+ * The function is exported as `omit_` because the top-level `Object` module
16
+ * already exposes an `omit` runtime helper.
17
+ */
18
+
19
+ /**
20
+ * Removes the given keys from an existing object validator and returns a new
21
+ * object validator covering the remaining keys.
22
+ * @template T - Original object shape
23
+ * @template K - Tuple of keys to omit from the original shape
24
+ * @param {ObjectValidator<T>} validator - Source object validator
25
+ * @param {K} keys - Keys to drop from the new validator
26
+ * @param {string} [message] - Custom error message for the omitted validator
27
+ * @returns {ObjectValidator<Omit<T, K[number]>>} - New validator without omitted keys
28
+ */
29
+ var omit_ = exports.omit_ = function omit_(validator, keys, message) {
30
+ var sourceShape = validator.shape;
31
+ var omittedKeys = new Set(keys);
32
+ var nextShape = {};
33
+ for (var key in sourceShape) {
34
+ if (!omittedKeys.has(key)) {
35
+ nextShape[key] = sourceShape[key];
36
+ }
37
+ }
38
+ return (0, _core.object)(nextShape, message);
39
+ };
@@ -1,8 +1,36 @@
1
- import type { ValidateCoreReturnType } from "../../Validate/type";
1
+ interface UndefinedReturn {
2
+ validate: boolean;
3
+ message: string;
4
+ type: "undefined";
5
+ }
6
+ /**
7
+ * Optional validator augmented with a reference to the wrapped validator,
8
+ * used by `required()` to unwrap optional layers when rebuilding a shape
9
+ * @template T - The type of value the wrapped validator expects
10
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
11
+ */
12
+ export type OptionalValidator<T, R extends {
13
+ type: unknown;
14
+ message: string;
15
+ validate: boolean;
16
+ } = {
17
+ type: unknown;
18
+ message: string;
19
+ validate: boolean;
20
+ }> = ((value?: T) => R | UndefinedReturn) & {
21
+ inner: (value: T) => R;
22
+ isOptional: true;
23
+ };
2
24
  /**
3
25
  * Wraps a validator to accept undefined values
4
26
  * @template T - The type of value the wrapped validator expects
27
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
5
28
  * @param {Function} validator - Validator function to make optional
6
- * @returns {Function} - Validator that passes for undefined or delegates to the wrapped validator
29
+ * @returns {OptionalValidator<T, R>} - Validator that passes for undefined or delegates to the wrapped validator
7
30
  */
8
- export declare const optional: <T>(validator: (value: T) => ValidateCoreReturnType<T>) => ((value?: T) => ValidateCoreReturnType<T | undefined>);
31
+ export declare const optional: <T, R extends {
32
+ type: unknown;
33
+ message: string;
34
+ validate: boolean;
35
+ }>(validator: (value: T) => R) => OptionalValidator<T, R>;
36
+ export {};
@@ -4,11 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.optional = void 0;
7
+ /**
8
+ * Optional validator augmented with a reference to the wrapped validator,
9
+ * used by `required()` to unwrap optional layers when rebuilding a shape
10
+ * @template T - The type of value the wrapped validator expects
11
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
12
+ */
13
+
7
14
  /**
8
15
  * Wraps a validator to accept undefined values
9
16
  * @template T - The type of value the wrapped validator expects
17
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
10
18
  * @param {Function} validator - Validator function to make optional
11
- * @returns {Function} - Validator that passes for undefined or delegates to the wrapped validator
19
+ * @returns {OptionalValidator<T, R>} - Validator that passes for undefined or delegates to the wrapped validator
12
20
  */
13
21
  var optional = exports.optional = function optional(validator) {
14
22
  var optionalValidator = function optionalValidator(value) {
@@ -19,8 +27,9 @@ var optional = exports.optional = function optional(validator) {
19
27
  type: "undefined"
20
28
  };
21
29
  }
22
- var result = validator(value);
23
- return result;
30
+ return validator(value);
24
31
  };
32
+ optionalValidator.inner = validator;
33
+ optionalValidator.isOptional = true;
25
34
  return optionalValidator;
26
35
  };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Object validation - partial
3
+ * Returns a new object validator where every key is wrapped in `optional()`,
4
+ * mirroring `Partial<T>` at the type level so consumers see all properties as
5
+ * optional.
6
+ */
7
+ import { type ObjectShape, type ObjectValidator } from "./core";
8
+ import { type OptionalValidator } from "./optional";
9
+ type PartialShape<T extends ObjectShape> = {
10
+ [K in keyof T]: OptionalValidator<Parameters<T[K]>[0], ReturnType<T[K]> extends {
11
+ type: unknown;
12
+ message: string;
13
+ validate: boolean;
14
+ } ? ReturnType<T[K]> : never>;
15
+ };
16
+ /**
17
+ * Wraps every property validator of `validator` with `optional()`. Validators
18
+ * that are already optional are kept as-is so the wrapper stays idempotent.
19
+ * @template T - Original object shape
20
+ * @param {ObjectValidator<T>} validator - Source object validator
21
+ * @param {string} [message] - Custom error message for the new validator
22
+ * @returns {ObjectValidator<PartialShape<T>>} - New validator where every key accepts undefined
23
+ */
24
+ export declare const partial: <T extends ObjectShape>(validator: ObjectValidator<T>, message?: string) => ObjectValidator<PartialShape<T>>;
25
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.partial = void 0;
7
+ var _core = require("./core");
8
+ var _optional = require("./optional");
9
+ /**
10
+ * Object validation - partial
11
+ * Returns a new object validator where every key is wrapped in `optional()`,
12
+ * mirroring `Partial<T>` at the type level so consumers see all properties as
13
+ * optional.
14
+ */
15
+
16
+ /**
17
+ * Wraps every property validator of `validator` with `optional()`. Validators
18
+ * that are already optional are kept as-is so the wrapper stays idempotent.
19
+ * @template T - Original object shape
20
+ * @param {ObjectValidator<T>} validator - Source object validator
21
+ * @param {string} [message] - Custom error message for the new validator
22
+ * @returns {ObjectValidator<PartialShape<T>>} - New validator where every key accepts undefined
23
+ */
24
+ var partial = exports.partial = function partial(validator, message) {
25
+ var sourceShape = validator.shape;
26
+ var nextShape = {};
27
+ for (var _i = 0, _Object$keys = Object.keys(sourceShape); _i < _Object$keys.length; _i++) {
28
+ var key = _Object$keys[_i];
29
+ var current = sourceShape[key];
30
+ nextShape[key] = current.isOptional === true ? current : (0, _optional.optional)(current);
31
+ }
32
+ return (0, _core.object)(nextShape, message);
33
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Object validation - pick
3
+ * Returns a new object validator that only checks the specified keys of the
4
+ * source validator. Mirrors `Pick<T, K>` at the type level so consumers like
5
+ * `union()`, `intersection()`, and `SchemaToInterface` see the narrowed shape.
6
+ *
7
+ * The function is exported as `pick_` because the top-level `Object` module
8
+ * already exposes a `pick` runtime helper.
9
+ */
10
+ import { type ObjectShape, type ObjectValidator } from "./core";
11
+ /**
12
+ * Picks the given keys from an existing object validator and returns a new
13
+ * object validator covering only those keys.
14
+ * @template T - Original object shape
15
+ * @template K - Tuple of keys to pick from the original shape
16
+ * @param {ObjectValidator<T>} validator - Source object validator
17
+ * @param {K} keys - Keys to retain on the new validator
18
+ * @param {string} [message] - Custom error message for the picked validator
19
+ * @returns {ObjectValidator<Pick<T, K[number]>>} - New validator scoped to picked keys
20
+ */
21
+ export declare const pick_: <T extends ObjectShape, K extends readonly (keyof T)[]>(validator: ObjectValidator<T>, keys: K, message?: string) => ObjectValidator<Pick<T, K[number]>>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pick_ = void 0;
7
+ var _core = require("./core");
8
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /**
11
+ * Object validation - pick
12
+ * Returns a new object validator that only checks the specified keys of the
13
+ * source validator. Mirrors `Pick<T, K>` at the type level so consumers like
14
+ * `union()`, `intersection()`, and `SchemaToInterface` see the narrowed shape.
15
+ *
16
+ * The function is exported as `pick_` because the top-level `Object` module
17
+ * already exposes a `pick` runtime helper.
18
+ */
19
+ /**
20
+ * Picks the given keys from an existing object validator and returns a new
21
+ * object validator covering only those keys.
22
+ * @template T - Original object shape
23
+ * @template K - Tuple of keys to pick from the original shape
24
+ * @param {ObjectValidator<T>} validator - Source object validator
25
+ * @param {K} keys - Keys to retain on the new validator
26
+ * @param {string} [message] - Custom error message for the picked validator
27
+ * @returns {ObjectValidator<Pick<T, K[number]>>} - New validator scoped to picked keys
28
+ */
29
+ var pick_ = exports.pick_ = function pick_(validator, keys, message) {
30
+ var sourceShape = validator.shape;
31
+ var nextShape = {};
32
+ var _iterator = _createForOfIteratorHelper(keys),
33
+ _step;
34
+ try {
35
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
+ var key = _step.value;
37
+ nextShape[key] = sourceShape[key];
38
+ }
39
+ } catch (err) {
40
+ _iterator.e(err);
41
+ } finally {
42
+ _iterator.f();
43
+ }
44
+ return (0, _core.object)(nextShape, message);
45
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Object validation - required
3
+ * Returns a new object validator where every key is unwrapped from any
4
+ * `optional()` layer, mirroring `Required<T>` at the type level so consumers
5
+ * see all properties as required again.
6
+ */
7
+ import { type ObjectShape, type ObjectValidator } from "./core";
8
+ import type { OptionalValidator } from "./optional";
9
+ type UnwrapOptional<V> = V extends OptionalValidator<infer Inner, infer R> ? (value: Inner) => R : V;
10
+ type RequiredShape<T extends ObjectShape> = {
11
+ [K in keyof T]: UnwrapOptional<T[K]> extends ObjectShape[string] ? UnwrapOptional<T[K]> : T[K];
12
+ };
13
+ /**
14
+ * Strips `optional()` wrappers from every property validator of `validator`.
15
+ * Validators that are not wrapped in `optional()` are kept as-is.
16
+ * @template T - Original object shape
17
+ * @param {ObjectValidator<T>} validator - Source object validator
18
+ * @param {string} [message] - Custom error message for the new validator
19
+ * @returns {ObjectValidator<RequiredShape<T>>} - New validator where every optional layer is removed
20
+ */
21
+ export declare const required: <T extends ObjectShape>(validator: ObjectValidator<T>, message?: string) => ObjectValidator<RequiredShape<T>>;
22
+ export {};