umt 2.19.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 (163) 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 +6 -1
  8. package/module/Validate/array/arrayOf.js +1 -0
  9. package/module/Validate/array/arrayOf.js.map +1 -1
  10. package/module/Validate/bigint/core.d.ts +24 -0
  11. package/module/Validate/bigint/core.js +37 -0
  12. package/module/Validate/bigint/core.js.map +1 -0
  13. package/module/Validate/bigint/index.d.ts +1 -0
  14. package/module/Validate/bigint/index.js +2 -0
  15. package/module/Validate/bigint/index.js.map +1 -0
  16. package/module/Validate/date/core.d.ts +14 -0
  17. package/module/Validate/date/core.js +29 -0
  18. package/module/Validate/date/core.js.map +1 -0
  19. package/module/Validate/date/index.d.ts +1 -0
  20. package/module/Validate/date/index.js +2 -0
  21. package/module/Validate/date/index.js.map +1 -0
  22. package/module/Validate/file/core.d.ts +13 -0
  23. package/module/Validate/file/core.js +32 -0
  24. package/module/Validate/file/core.js.map +1 -0
  25. package/module/Validate/file/index.d.ts +1 -0
  26. package/module/Validate/file/index.js +2 -0
  27. package/module/Validate/file/index.js.map +1 -0
  28. package/module/Validate/function/core.d.ts +75 -0
  29. package/module/Validate/function/core.js +66 -0
  30. package/module/Validate/function/core.js.map +1 -0
  31. package/module/Validate/function/index.d.ts +1 -0
  32. package/module/Validate/function/index.js +2 -0
  33. package/module/Validate/function/index.js.map +1 -0
  34. package/module/Validate/index.d.ts +11 -0
  35. package/module/Validate/index.js +11 -0
  36. package/module/Validate/index.js.map +1 -1
  37. package/module/Validate/instanceof/core.d.ts +19 -0
  38. package/module/Validate/instanceof/core.js +32 -0
  39. package/module/Validate/instanceof/core.js.map +1 -0
  40. package/module/Validate/instanceof/index.d.ts +1 -0
  41. package/module/Validate/instanceof/index.js +2 -0
  42. package/module/Validate/instanceof/index.js.map +1 -0
  43. package/module/Validate/map/core.d.ts +24 -0
  44. package/module/Validate/map/core.js +57 -0
  45. package/module/Validate/map/core.js.map +1 -0
  46. package/module/Validate/map/index.d.ts +1 -0
  47. package/module/Validate/map/index.js +2 -0
  48. package/module/Validate/map/index.js.map +1 -0
  49. package/module/Validate/never/core.d.ts +22 -0
  50. package/module/Validate/never/core.js +23 -0
  51. package/module/Validate/never/core.js.map +1 -0
  52. package/module/Validate/never/index.d.ts +1 -0
  53. package/module/Validate/never/index.js +2 -0
  54. package/module/Validate/never/index.js.map +1 -0
  55. package/module/Validate/object/core.d.ts +22 -4
  56. package/module/Validate/object/core.js +5 -3
  57. package/module/Validate/object/core.js.map +1 -1
  58. package/module/Validate/object/index.d.ts +4 -0
  59. package/module/Validate/object/index.js +4 -0
  60. package/module/Validate/object/index.js.map +1 -1
  61. package/module/Validate/object/nullable.d.ts +12 -2
  62. package/module/Validate/object/nullable.js +2 -2
  63. package/module/Validate/object/nullable.js.map +1 -1
  64. package/module/Validate/object/omit.d.ts +22 -0
  65. package/module/Validate/object/omit.js +33 -0
  66. package/module/Validate/object/omit.js.map +1 -0
  67. package/module/Validate/object/optional.d.ts +31 -3
  68. package/module/Validate/object/optional.js +7 -5
  69. package/module/Validate/object/optional.js.map +1 -1
  70. package/module/Validate/object/partial.d.ts +25 -0
  71. package/module/Validate/object/partial.js +29 -0
  72. package/module/Validate/object/partial.js.map +1 -0
  73. package/module/Validate/object/pick.d.ts +21 -0
  74. package/module/Validate/object/pick.js +29 -0
  75. package/module/Validate/object/pick.js.map +1 -0
  76. package/module/Validate/object/required.d.ts +22 -0
  77. package/module/Validate/object/required.js +30 -0
  78. package/module/Validate/object/required.js.map +1 -0
  79. package/module/Validate/set/core.d.ts +24 -0
  80. package/module/Validate/set/core.js +47 -0
  81. package/module/Validate/set/core.js.map +1 -0
  82. package/module/Validate/set/index.d.ts +1 -0
  83. package/module/Validate/set/index.js +2 -0
  84. package/module/Validate/set/index.js.map +1 -0
  85. package/module/Validate/templateLiteral/core.d.ts +55 -0
  86. package/module/Validate/templateLiteral/core.js +68 -0
  87. package/module/Validate/templateLiteral/core.js.map +1 -0
  88. package/module/Validate/templateLiteral/index.d.ts +1 -0
  89. package/module/Validate/templateLiteral/index.js +2 -0
  90. package/module/Validate/templateLiteral/index.js.map +1 -0
  91. package/module/Validate/type.d.ts +7 -5
  92. package/module/Validate/unknown/core.d.ts +21 -0
  93. package/module/Validate/unknown/core.js +16 -0
  94. package/module/Validate/unknown/core.js.map +1 -0
  95. package/module/Validate/unknown/index.d.ts +1 -0
  96. package/module/Validate/unknown/index.js +2 -0
  97. package/module/Validate/unknown/index.js.map +1 -0
  98. package/module/es5/Validate/any/core.d.ts +21 -0
  99. package/module/es5/Validate/any/core.js +36 -0
  100. package/module/es5/Validate/any/index.d.ts +1 -0
  101. package/module/es5/Validate/any/index.js +16 -0
  102. package/module/es5/Validate/array/arrayOf.d.ts +6 -1
  103. package/module/es5/Validate/array/arrayOf.js +1 -0
  104. package/module/es5/Validate/bigint/core.d.ts +24 -0
  105. package/module/es5/Validate/bigint/core.js +65 -0
  106. package/module/es5/Validate/bigint/index.d.ts +1 -0
  107. package/module/es5/Validate/bigint/index.js +16 -0
  108. package/module/es5/Validate/date/core.d.ts +14 -0
  109. package/module/es5/Validate/date/core.js +35 -0
  110. package/module/es5/Validate/date/index.d.ts +1 -0
  111. package/module/es5/Validate/date/index.js +16 -0
  112. package/module/es5/Validate/file/core.d.ts +13 -0
  113. package/module/es5/Validate/file/core.js +39 -0
  114. package/module/es5/Validate/file/index.d.ts +1 -0
  115. package/module/es5/Validate/file/index.js +16 -0
  116. package/module/es5/Validate/function/core.d.ts +75 -0
  117. package/module/es5/Validate/function/core.js +125 -0
  118. package/module/es5/Validate/function/index.d.ts +1 -0
  119. package/module/es5/Validate/function/index.js +16 -0
  120. package/module/es5/Validate/index.d.ts +11 -0
  121. package/module/es5/Validate/index.js +121 -0
  122. package/module/es5/Validate/instanceof/core.d.ts +19 -0
  123. package/module/es5/Validate/instanceof/core.js +40 -0
  124. package/module/es5/Validate/instanceof/index.d.ts +1 -0
  125. package/module/es5/Validate/instanceof/index.js +16 -0
  126. package/module/es5/Validate/map/core.d.ts +24 -0
  127. package/module/es5/Validate/map/core.js +81 -0
  128. package/module/es5/Validate/map/index.d.ts +1 -0
  129. package/module/es5/Validate/map/index.js +16 -0
  130. package/module/es5/Validate/never/core.d.ts +22 -0
  131. package/module/es5/Validate/never/core.js +35 -0
  132. package/module/es5/Validate/never/index.d.ts +1 -0
  133. package/module/es5/Validate/never/index.js +16 -0
  134. package/module/es5/Validate/object/core.d.ts +22 -4
  135. package/module/es5/Validate/object/core.js +14 -2
  136. package/module/es5/Validate/object/index.d.ts +4 -0
  137. package/module/es5/Validate/object/index.js +44 -0
  138. package/module/es5/Validate/object/nullable.d.ts +12 -2
  139. package/module/es5/Validate/object/nullable.js +2 -2
  140. package/module/es5/Validate/object/omit.d.ts +22 -0
  141. package/module/es5/Validate/object/omit.js +39 -0
  142. package/module/es5/Validate/object/optional.d.ts +31 -3
  143. package/module/es5/Validate/object/optional.js +12 -3
  144. package/module/es5/Validate/object/partial.d.ts +25 -0
  145. package/module/es5/Validate/object/partial.js +33 -0
  146. package/module/es5/Validate/object/pick.d.ts +21 -0
  147. package/module/es5/Validate/object/pick.js +45 -0
  148. package/module/es5/Validate/object/required.d.ts +22 -0
  149. package/module/es5/Validate/object/required.js +33 -0
  150. package/module/es5/Validate/set/core.d.ts +24 -0
  151. package/module/es5/Validate/set/core.js +65 -0
  152. package/module/es5/Validate/set/index.d.ts +1 -0
  153. package/module/es5/Validate/set/index.js +16 -0
  154. package/module/es5/Validate/templateLiteral/core.d.ts +55 -0
  155. package/module/es5/Validate/templateLiteral/core.js +114 -0
  156. package/module/es5/Validate/templateLiteral/index.d.ts +1 -0
  157. package/module/es5/Validate/templateLiteral/index.js +16 -0
  158. package/module/es5/Validate/type.d.ts +7 -5
  159. package/module/es5/Validate/unknown/core.d.ts +21 -0
  160. package/module/es5/Validate/unknown/core.js +34 -0
  161. package/module/es5/Validate/unknown/index.d.ts +1 -0
  162. package/module/es5/Validate/unknown/index.js +16 -0
  163. package/package.json +1 -1
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Set validation core module
3
+ * Provides validation for `Set` instances. The validator can optionally
4
+ * delegate to a per-element validator, mirroring how `arrayOf()` validates
5
+ * each element of an array.
6
+ *
7
+ * The function is exported as `set_` because the top-level `Object` module
8
+ * already exposes a `set` runtime helper.
9
+ */
10
+ /**
11
+ * Creates a Set validator. When a per-element validator is supplied, every
12
+ * element of the set must satisfy it; iteration short-circuits at the first
13
+ * failure and surfaces the failing message.
14
+ * @template IV - Validator for set elements
15
+ * @param {IV} [itemValidator] - Validator applied to every element
16
+ * @param {string} [message] - Custom error message for type validation
17
+ * @returns {Function} - Validator function for Set instances
18
+ */
19
+ export const set_ = (itemValidator, message) => {
20
+ return (value) => {
21
+ if (!(value instanceof Set)) {
22
+ return {
23
+ validate: false,
24
+ message: message ?? "",
25
+ type: value,
26
+ };
27
+ }
28
+ if (itemValidator) {
29
+ for (const item of value) {
30
+ const result = itemValidator(item);
31
+ if (!result.validate) {
32
+ return {
33
+ validate: false,
34
+ message: result.message,
35
+ type: value,
36
+ };
37
+ }
38
+ }
39
+ }
40
+ return {
41
+ validate: true,
42
+ message: "",
43
+ type: value,
44
+ };
45
+ };
46
+ };
47
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/set/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAOlB,aAAkB,EAClB,OAAgB,EAChB,EAAE;IACF,OAAO,CAAC,KAAa,EAAkC,EAAE;QACvD,IAAI,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,IAAI,aAAa,EAAE,CAAC;YAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,MAAM,GACV,aAID,CAAC,IAAI,CAAC,CAAC;gBACR,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;oBACrB,OAAO;wBACL,QAAQ,EAAE,KAAK;wBACf,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,IAAI,EAAE,KAAK;qBACZ,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./core";
@@ -0,0 +1,2 @@
1
+ export * from "./core";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/set/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Template literal validation core module
3
+ * Provides a validator that checks whether a string matches a template
4
+ * literal pattern composed of string fragments and primitive validators
5
+ * (string / number / boolean / bigint). The runtime check is performed by
6
+ * an auto-generated regular expression assembled from the parts, while the
7
+ * inferred type is the corresponding TypeScript template literal type.
8
+ */
9
+ import type { ValidateType } from "../../Validate/type";
10
+ type AnyValidator = (value?: any) => {
11
+ type: unknown;
12
+ };
13
+ /**
14
+ * Allowed parts of a template literal definition. Each element is either a
15
+ * string literal that must appear verbatim, or a primitive validator whose
16
+ * accepted shape is converted to a regex fragment at construction time.
17
+ */
18
+ export type TemplateLiteralPart = string | AnyValidator;
19
+ type ExtractValidatorTag<V> = V extends (value: never) => {
20
+ type: infer T;
21
+ } ? T : never;
22
+ type TagToTemplate<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "bigint" ? bigint : ValidateType<T>;
23
+ type PartToTemplate<P> = P extends string ? P : TagToTemplate<ExtractValidatorTag<P>>;
24
+ /**
25
+ * Builds the template literal type produced by joining `Parts`. Each part is
26
+ * mapped to either its literal string value or to the runtime type that the
27
+ * corresponding validator accepts.
28
+ */
29
+ export type BuildTemplateLiteral<Parts extends readonly TemplateLiteralPart[]> = Parts extends readonly [
30
+ infer Head,
31
+ ...infer Tail extends readonly TemplateLiteralPart[]
32
+ ] ? `${Extract<PartToTemplate<Head>, string | number | bigint | boolean>}${BuildTemplateLiteral<Tail>}` : "";
33
+ /**
34
+ * Return type produced by a `templateLiteral` validator. Preserves the
35
+ * literal template string type through the `type` field so consumers like
36
+ * `union()`, `intersection()`, and `SchemaToInterface` can recover it.
37
+ * @template T - The inferred template literal type
38
+ */
39
+ export interface TemplateLiteralReturnType<T extends string> {
40
+ validate: boolean;
41
+ message: string;
42
+ type: T;
43
+ }
44
+ /**
45
+ * Creates a validator that checks whether a value matches a template literal
46
+ * pattern. Each part is either a string literal that must appear verbatim or
47
+ * a primitive validator (string / number / boolean / bigint) that contributes
48
+ * a regex fragment.
49
+ * @template Parts - Tuple describing the template parts
50
+ * @param {Parts} parts - Tuple of literal strings and primitive validators
51
+ * @param {string} [message] - Custom error message for validation failure
52
+ * @returns {Function} - Validator function for template literal strings
53
+ */
54
+ export declare const templateLiteral: <const Parts extends readonly TemplateLiteralPart[]>(parts: Parts, message?: string) => (value: BuildTemplateLiteral<Parts>) => TemplateLiteralReturnType<BuildTemplateLiteral<Parts>>;
55
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Template literal validation core module
3
+ * Provides a validator that checks whether a string matches a template
4
+ * literal pattern composed of string fragments and primitive validators
5
+ * (string / number / boolean / bigint). The runtime check is performed by
6
+ * an auto-generated regular expression assembled from the parts, while the
7
+ * inferred type is the corresponding TypeScript template literal type.
8
+ */
9
+ const escapeRegex = (input) => input.replaceAll(/[$()*+.?[\\\]^{|}]/g, String.raw `\$&`);
10
+ const tagToPattern = (tag) => {
11
+ switch (tag) {
12
+ case "string": {
13
+ return ".*?";
14
+ }
15
+ case "number": {
16
+ return String.raw `-?(?:\d+\.\d+|\d+(?:\.\d*)?|\.\d+)`;
17
+ }
18
+ case "boolean": {
19
+ return "(?:true|false)";
20
+ }
21
+ case "bigint": {
22
+ return String.raw `-?\d+`;
23
+ }
24
+ default: {
25
+ return ".+?";
26
+ }
27
+ }
28
+ };
29
+ const detectValidatorTag = (validator) => {
30
+ const result = validator();
31
+ return result?.type;
32
+ };
33
+ /**
34
+ * Creates a validator that checks whether a value matches a template literal
35
+ * pattern. Each part is either a string literal that must appear verbatim or
36
+ * a primitive validator (string / number / boolean / bigint) that contributes
37
+ * a regex fragment.
38
+ * @template Parts - Tuple describing the template parts
39
+ * @param {Parts} parts - Tuple of literal strings and primitive validators
40
+ * @param {string} [message] - Custom error message for validation failure
41
+ * @returns {Function} - Validator function for template literal strings
42
+ */
43
+ export const templateLiteral = (parts, message) => {
44
+ let pattern = "^";
45
+ for (const part of parts) {
46
+ pattern +=
47
+ typeof part === "string"
48
+ ? escapeRegex(part)
49
+ : `(?:${tagToPattern(detectValidatorTag(part))})`;
50
+ }
51
+ pattern += "$";
52
+ const regex = new RegExp(pattern);
53
+ return (value) => {
54
+ if (typeof value !== "string" || !regex.test(value)) {
55
+ return {
56
+ validate: false,
57
+ message: message ?? "",
58
+ type: value,
59
+ };
60
+ }
61
+ return {
62
+ validate: true,
63
+ message: "",
64
+ type: value,
65
+ };
66
+ };
67
+ };
68
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/templateLiteral/core.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAyDH,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE,CAC5C,KAAK,CAAC,UAAU,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG,CAAA,KAAK,CAAC,CAAC;AAE3D,MAAM,YAAY,GAAG,CAAC,GAAY,EAAU,EAAE;IAC5C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,MAAM,CAAC,GAAG,CAAA,oCAAoC,CAAC;QACxD,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,MAAM,CAAC,GAAG,CAAA,OAAO,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,SAAuB,EAAW,EAAE;IAC9D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,MAAM,EAAE,IAAI,CAAC;AACtB,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAG7B,KAAY,EACZ,OAAgB,EAChB,EAAE;IACF,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,IAAI,KAAK,QAAQ;gBACtB,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;gBACnB,CAAC,CAAC,MAAM,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,GAAG,CAAC;IACf,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;IAElC,OAAO,CACL,KAAkC,EACsB,EAAE;QAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACpD,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./core";
@@ -0,0 +1,2 @@
1
+ export * from "./core";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/templateLiteral/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -1,11 +1,12 @@
1
1
  export type _Types<T> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T;
2
2
  export type _Types2<T> = T extends undefined ? "undefined" : T extends null ? "null" : T;
3
+ export type _Types3<T> = T extends bigint ? "bigint" : T;
3
4
  /**
4
5
  * Maps TypeScript types to their string literal representations
5
6
  * @template T - The type to map
6
- * @returns "string" for string, "number" for number, "boolean" for boolean, or the original type T otherwise
7
+ * @returns "string" for string, "number" for number, "boolean" for boolean, "bigint" for bigint, or the original type T otherwise
7
8
  */
8
- export type Types<T> = T extends string | number | boolean ? _Types<T> : T extends undefined | null ? _Types2<T> : T;
9
+ export type Types<T> = T extends string | number | boolean ? _Types<T> : T extends undefined | null ? _Types2<T> : T extends bigint ? _Types3<T> : T;
9
10
  /**
10
11
  * Core validation result type including validation status, message, and type information
11
12
  * @template T - The type being validated
@@ -31,12 +32,13 @@ export interface ValidateReturnType<T> {
31
32
  export type ValidateFunctionType<T> = (value: T) => boolean;
32
33
  export type _ValidateType<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T;
33
34
  export type _ValidateType2<T> = T extends "undefined" ? undefined : T extends "null" ? null : T;
35
+ export type _ValidateType3<T> = T extends "bigint" ? bigint : T extends "any" ? any : T extends "unknown" ? unknown : T extends "never" ? never : T;
34
36
  /**
35
37
  * Maps string literal type names back to their TypeScript types
36
- * @template T - The string literal type name ("string", "number", "boolean")
37
- * @returns The corresponding TypeScript type (string, number, boolean) or the original type T
38
+ * @template T - The string literal type name ("string", "number", "boolean", "bigint", "undefined", "null", "any", "unknown", "never")
39
+ * @returns The corresponding TypeScript type or the original type T when no tag matches
38
40
  */
39
- export type ValidateType<T> = T extends "string" | "number" | "boolean" ? _ValidateType<T> : T extends "undefined" | "null" ? _ValidateType2<T> : T;
41
+ export type ValidateType<T> = T extends "string" | "number" | "boolean" ? _ValidateType<T> : T extends "undefined" | "null" ? _ValidateType2<T> : T extends "bigint" | "any" | "unknown" | "never" ? _ValidateType3<T> : T;
40
42
  export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ValidateType<ReturnType<T>["type"]>;
41
43
  export type OptionalKeys<T> = {
42
44
  [K in keyof T]: undefined extends T[K] ? K : never;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Unknown validation core module
3
+ * Provides a validator that accepts any value but exposes it as `unknown`
4
+ * to keep callers honest about narrowing before use.
5
+ */
6
+ /**
7
+ * Return type produced by an `unknown` validator. Exposes the literal
8
+ * `"unknown"` tag through the `type` field so `ValidateType<"unknown">` can
9
+ * map it back to the `unknown` runtime type when consumed by downstream
10
+ * helpers.
11
+ */
12
+ export interface UnknownReturnType {
13
+ validate: boolean;
14
+ message: string;
15
+ type: "unknown";
16
+ }
17
+ /**
18
+ * Creates a validator that accepts any value but typed as unknown
19
+ * @returns {Function} - Validator that always succeeds
20
+ */
21
+ export declare const unknown: () => ((value: unknown) => UnknownReturnType);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Unknown validation core module
3
+ * Provides a validator that accepts any value but exposes it as `unknown`
4
+ * to keep callers honest about narrowing before use.
5
+ */
6
+ const unknownValidator = (_value) => ({
7
+ validate: true,
8
+ message: "",
9
+ type: "unknown",
10
+ });
11
+ /**
12
+ * Creates a validator that accepts any value but typed as unknown
13
+ * @returns {Function} - Validator that always succeeds
14
+ */
15
+ export const unknown = () => unknownValidator;
16
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/unknown/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAqB,EAAE,CAAC,CAAC;IAChE,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAA4C,EAAE,CACnE,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./core";
@@ -0,0 +1,2 @@
1
+ export * from "./core";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/unknown/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Any validation core module
3
+ * Provides a validator that accepts any value, useful when a position in a
4
+ * schema needs to remain wide open while still participating in `object()`,
5
+ * `union()`, `intersection()`, and other compositional helpers.
6
+ */
7
+ /**
8
+ * Return type produced by an `any` validator. Exposes the literal `"any"`
9
+ * tag through the `type` field so `ValidateType<"any">` can map it back to
10
+ * the `any` runtime type when consumed by downstream helpers.
11
+ */
12
+ export interface AnyReturnType {
13
+ validate: boolean;
14
+ message: string;
15
+ type: "any";
16
+ }
17
+ /**
18
+ * Creates a validator that accepts any value
19
+ * @returns {Function} - Validator that always succeeds
20
+ */
21
+ export declare const any: () => ((value: any) => AnyReturnType);
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.any = void 0;
7
+ /**
8
+ * Any validation core module
9
+ * Provides a validator that accepts any value, useful when a position in a
10
+ * schema needs to remain wide open while still participating in `object()`,
11
+ * `union()`, `intersection()`, and other compositional helpers.
12
+ */
13
+
14
+ /**
15
+ * Return type produced by an `any` validator. Exposes the literal `"any"`
16
+ * tag through the `type` field so `ValidateType<"any">` can map it back to
17
+ * the `any` runtime type when consumed by downstream helpers.
18
+ */
19
+
20
+ // biome-ignore lint/suspicious/noExplicitAny: signature mirrors the return type
21
+ var anyValidator = function anyValidator(_value) {
22
+ return {
23
+ validate: true,
24
+ message: "",
25
+ type: "any"
26
+ };
27
+ };
28
+
29
+ /**
30
+ * Creates a validator that accepts any value
31
+ * @returns {Function} - Validator that always succeeds
32
+ */
33
+ // biome-ignore lint/suspicious/noExplicitAny: any() must accept and infer any value
34
+ var any = exports.any = function any() {
35
+ return anyValidator;
36
+ };
@@ -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
+ });
@@ -2,8 +2,13 @@ import type { ValidateCoreReturnType } from "../../Validate/type";
2
2
  /**
3
3
  * Creates an array validator that validates every element with a single validator
4
4
  * @template T - Element type validated by the wrapped validator
5
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
5
6
  * @param {Function} validator - Validator applied to each element (e.g. an object validator)
6
7
  * @param {string} [message] - Custom error message for array type validation
7
8
  * @returns {Function} - Validator function for arrays whose elements satisfy the given validator
8
9
  */
9
- export declare const arrayOf: <T>(validator: (value: T) => ValidateCoreReturnType<T>, message?: string) => (values: T[]) => ValidateCoreReturnType<T[]>;
10
+ export declare const arrayOf: <T, R extends {
11
+ type: unknown;
12
+ message: string;
13
+ validate: boolean;
14
+ }>(validator: (value: T) => R, message?: string) => (values: T[]) => ValidateCoreReturnType<T[]>;
@@ -11,6 +11,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
11
11
  /**
12
12
  * Creates an array validator that validates every element with a single validator
13
13
  * @template T - Element type validated by the wrapped validator
14
+ * @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
14
15
  * @param {Function} validator - Validator applied to each element (e.g. an object validator)
15
16
  * @param {string} [message] - Custom error message for array type validation
16
17
  * @returns {Function} - Validator function for arrays whose elements satisfy the given validator
@@ -0,0 +1,24 @@
1
+ /**
2
+ * BigInt validation core module
3
+ * Provides the base validation functionality for bigint values
4
+ */
5
+ import type { ValidateReturnType } from "../../Validate/type";
6
+ /**
7
+ * Return type produced by a `bigint` validator. Structurally compatible with
8
+ * `ValidateCoreReturnType<bigint>`, but exposes the literal `"bigint"` tag
9
+ * through the `type` field so `ValidateType<"bigint">` can map it back to the
10
+ * `bigint` runtime type when consumed by `object()`, `union()`, and friends.
11
+ */
12
+ export interface BigIntReturnType {
13
+ validate: boolean;
14
+ message: string;
15
+ type: "bigint";
16
+ }
17
+ /**
18
+ * Creates a bigint validator with optional validation rules
19
+ * @template T - Array of validation rules for bigints
20
+ * @param {T} [option] - Array of validation functions to apply
21
+ * @param {string} [message] - Custom error message for type validation
22
+ * @returns {Function} - Validator function that checks if the value is a bigint and applies validation rules
23
+ */
24
+ export declare const bigint: <T extends ValidateReturnType<bigint>[]>(option?: T, message?: string) => (value: bigint) => BigIntReturnType;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.bigint = void 0;
7
+ 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; } } }; }
8
+ 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; } }
9
+ 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; }
10
+ /**
11
+ * BigInt validation core module
12
+ * Provides the base validation functionality for bigint values
13
+ */
14
+
15
+ /**
16
+ * Return type produced by a `bigint` validator. Structurally compatible with
17
+ * `ValidateCoreReturnType<bigint>`, but exposes the literal `"bigint"` tag
18
+ * through the `type` field so `ValidateType<"bigint">` can map it back to the
19
+ * `bigint` runtime type when consumed by `object()`, `union()`, and friends.
20
+ */
21
+
22
+ /**
23
+ * Creates a bigint validator with optional validation rules
24
+ * @template T - Array of validation rules for bigints
25
+ * @param {T} [option] - Array of validation functions to apply
26
+ * @param {string} [message] - Custom error message for type validation
27
+ * @returns {Function} - Validator function that checks if the value is a bigint and applies validation rules
28
+ */
29
+ var bigint = exports.bigint = function bigint() {
30
+ var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
31
+ var message = arguments.length > 1 ? arguments[1] : undefined;
32
+ return function (value) {
33
+ if (typeof value !== "bigint") {
34
+ return {
35
+ validate: false,
36
+ message: message !== null && message !== void 0 ? message : "",
37
+ type: "bigint"
38
+ };
39
+ }
40
+ var _iterator = _createForOfIteratorHelper(option),
41
+ _step;
42
+ try {
43
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
+ var rule = _step.value;
45
+ if (!rule.validate(value)) {
46
+ var _rule$message;
47
+ return {
48
+ validate: false,
49
+ message: (_rule$message = rule.message) !== null && _rule$message !== void 0 ? _rule$message : "",
50
+ type: "bigint"
51
+ };
52
+ }
53
+ }
54
+ } catch (err) {
55
+ _iterator.e(err);
56
+ } finally {
57
+ _iterator.f();
58
+ }
59
+ return {
60
+ validate: true,
61
+ message: "",
62
+ type: "bigint"
63
+ };
64
+ };
65
+ };
@@ -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,14 @@
1
+ /**
2
+ * Date validation core module
3
+ * Provides the base validation functionality for Date instances
4
+ */
5
+ import type { ValidateCoreReturnType } from "../../Validate/type";
6
+ /**
7
+ * Creates a Date validator. The validator checks both that the value is an
8
+ * instance of Date and that it represents a valid moment in time (i.e. its
9
+ * underlying timestamp is not NaN), so values created from invalid inputs
10
+ * such as `new Date("not-a-date")` are rejected.
11
+ * @param {string} [message] - Custom error message for type validation
12
+ * @returns {Function} - Validator function that checks if the value is a Date instance
13
+ */
14
+ export declare const date: (message?: string) => (value: Date) => ValidateCoreReturnType<Date>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.date = void 0;
7
+ /**
8
+ * Date validation core module
9
+ * Provides the base validation functionality for Date instances
10
+ */
11
+
12
+ /**
13
+ * Creates a Date validator. The validator checks both that the value is an
14
+ * instance of Date and that it represents a valid moment in time (i.e. its
15
+ * underlying timestamp is not NaN), so values created from invalid inputs
16
+ * such as `new Date("not-a-date")` are rejected.
17
+ * @param {string} [message] - Custom error message for type validation
18
+ * @returns {Function} - Validator function that checks if the value is a Date instance
19
+ */
20
+ var date = exports.date = function date(message) {
21
+ return function (value) {
22
+ if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
23
+ return {
24
+ validate: false,
25
+ message: message !== null && message !== void 0 ? message : "",
26
+ type: value
27
+ };
28
+ }
29
+ return {
30
+ validate: true,
31
+ message: "",
32
+ type: value
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
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * File validation core module
3
+ * Provides validation for File / Blob instances. Falls back to `Blob` when
4
+ * the global `File` constructor is unavailable.
5
+ */
6
+ import type { ValidateCoreReturnType } from "../../Validate/type";
7
+ /**
8
+ * Creates a validator that checks whether a value is a `File` (or `Blob` in
9
+ * runtimes where `File` is not available)
10
+ * @param {string} [message] - Custom error message for type validation
11
+ * @returns {Function} - Validator function for File / Blob instances
12
+ */
13
+ export declare const file: (message?: string) => (value: File) => ValidateCoreReturnType<File>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.file = void 0;
7
+ /**
8
+ * File validation core module
9
+ * Provides validation for File / Blob instances. Falls back to `Blob` when
10
+ * the global `File` constructor is unavailable.
11
+ */
12
+
13
+ var hasFileConstructor = typeof File !== "undefined";
14
+ var hasBlobConstructor = typeof Blob !== "undefined";
15
+
16
+ /**
17
+ * Creates a validator that checks whether a value is a `File` (or `Blob` in
18
+ * runtimes where `File` is not available)
19
+ * @param {string} [message] - Custom error message for type validation
20
+ * @returns {Function} - Validator function for File / Blob instances
21
+ */
22
+ var file = exports.file = function file(message) {
23
+ return function (value) {
24
+ var isFile = hasFileConstructor && value instanceof File;
25
+ var isBlob = hasBlobConstructor && value instanceof Blob;
26
+ if (!(isFile || isBlob)) {
27
+ return {
28
+ validate: false,
29
+ message: message !== null && message !== void 0 ? message : "",
30
+ type: value
31
+ };
32
+ }
33
+ return {
34
+ validate: true,
35
+ message: "",
36
+ type: value
37
+ };
38
+ };
39
+ };
@@ -0,0 +1 @@
1
+ export * from "./core";