@forklaunch/validator 0.3.12 → 0.4.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 (75) hide show
  1. package/lib/index-V6qNDTlr.d.mts +476 -0
  2. package/lib/index-V6qNDTlr.d.ts +476 -0
  3. package/lib/index.d.mts +6 -0
  4. package/lib/index.d.ts +6 -2
  5. package/lib/index.js +18 -1
  6. package/lib/index.mjs +0 -0
  7. package/lib/src/typebox/index.d.mts +220 -0
  8. package/lib/src/typebox/index.d.ts +220 -3
  9. package/lib/src/typebox/index.js +448 -1
  10. package/lib/src/typebox/index.mjs +406 -0
  11. package/lib/src/zod/index.d.mts +106 -0
  12. package/lib/src/zod/index.d.ts +106 -3
  13. package/lib/src/zod/index.js +291 -1
  14. package/lib/src/zod/index.mjs +244 -0
  15. package/lib/tests/utils/mockSchemaValidator.d.mts +69 -0
  16. package/lib/tests/utils/mockSchemaValidator.d.ts +29 -25
  17. package/lib/tests/utils/mockSchemaValidator.js +143 -79
  18. package/lib/tests/utils/mockSchemaValidator.mjs +99 -0
  19. package/package.json +21 -8
  20. package/lib/index.d.ts.map +0 -1
  21. package/lib/src/shared/types/schema.types.d.ts +0 -255
  22. package/lib/src/shared/types/schema.types.d.ts.map +0 -1
  23. package/lib/src/shared/types/schema.types.js +0 -1
  24. package/lib/src/typebox/index.d.ts.map +0 -1
  25. package/lib/src/typebox/staticSchemaValidator.d.ts +0 -99
  26. package/lib/src/typebox/staticSchemaValidator.d.ts.map +0 -1
  27. package/lib/src/typebox/staticSchemaValidator.js +0 -99
  28. package/lib/src/typebox/typeboxSchemaValidator.d.ts +0 -122
  29. package/lib/src/typebox/typeboxSchemaValidator.d.ts.map +0 -1
  30. package/lib/src/typebox/typeboxSchemaValidator.js +0 -362
  31. package/lib/src/typebox/types/schema.types.d.ts +0 -59
  32. package/lib/src/typebox/types/schema.types.d.ts.map +0 -1
  33. package/lib/src/typebox/types/schema.types.js +0 -1
  34. package/lib/src/zod/index.d.ts.map +0 -1
  35. package/lib/src/zod/staticSchemaValidator.d.ts +0 -99
  36. package/lib/src/zod/staticSchemaValidator.d.ts.map +0 -1
  37. package/lib/src/zod/staticSchemaValidator.js +0 -99
  38. package/lib/src/zod/types/schema.types.d.ts +0 -71
  39. package/lib/src/zod/types/schema.types.d.ts.map +0 -1
  40. package/lib/src/zod/types/schema.types.js +0 -1
  41. package/lib/src/zod/zodSchemaValidator.d.ts +0 -110
  42. package/lib/src/zod/zodSchemaValidator.d.ts.map +0 -1
  43. package/lib/src/zod/zodSchemaValidator.js +0 -192
  44. package/lib/tests/typebox/advancedParse.test.d.ts +0 -2
  45. package/lib/tests/typebox/advancedParse.test.d.ts.map +0 -1
  46. package/lib/tests/typebox/advancedParse.test.js +0 -514
  47. package/lib/tests/typebox/largeSchema.test.d.ts +0 -2
  48. package/lib/tests/typebox/largeSchema.test.d.ts.map +0 -1
  49. package/lib/tests/typebox/largeSchema.test.js +0 -150
  50. package/lib/tests/typebox/schemaValidator.test.d.ts +0 -2
  51. package/lib/tests/typebox/schemaValidator.test.d.ts.map +0 -1
  52. package/lib/tests/typebox/schemaValidator.test.js +0 -253
  53. package/lib/tests/typebox/typeEquality.test.d.ts +0 -2
  54. package/lib/tests/typebox/typeEquality.test.d.ts.map +0 -1
  55. package/lib/tests/typebox/typeEquality.test.js +0 -100
  56. package/lib/tests/utils/compare.d.ts +0 -2
  57. package/lib/tests/utils/compare.d.ts.map +0 -1
  58. package/lib/tests/utils/compare.js +0 -8
  59. package/lib/tests/utils/mockSchemaValidator.d.ts.map +0 -1
  60. package/lib/tests/zod/advancedParse.test.d.ts +0 -2
  61. package/lib/tests/zod/advancedParse.test.d.ts.map +0 -1
  62. package/lib/tests/zod/advancedParse.test.js +0 -514
  63. package/lib/tests/zod/largeSchema.test.d.ts +0 -2
  64. package/lib/tests/zod/largeSchema.test.d.ts.map +0 -1
  65. package/lib/tests/zod/largeSchema.test.js +0 -150
  66. package/lib/tests/zod/schemaValidator.test.d.ts +0 -2
  67. package/lib/tests/zod/schemaValidator.test.d.ts.map +0 -1
  68. package/lib/tests/zod/schemaValidator.test.js +0 -205
  69. package/lib/tests/zod/typeEquality.test.d.ts +0 -2
  70. package/lib/tests/zod/typeEquality.test.d.ts.map +0 -1
  71. package/lib/tests/zod/typeEquality.test.js +0 -100
  72. package/lib/tsconfig.tsbuildinfo +0 -1
  73. package/lib/vitest.config.d.ts +0 -3
  74. package/lib/vitest.config.d.ts.map +0 -1
  75. package/lib/vitest.config.js +0 -7
@@ -0,0 +1,476 @@
1
+ import { Prettify } from '@forklaunch/common';
2
+ import { SchemaObject } from 'openapi3-ts/oas31';
3
+ import { TObject as TObject$1, TNever, StaticDecode, TUnknown, TLiteral, TSchema, TKind, TProperties } from '@sinclair/typebox';
4
+ import { TypeCheck } from '@sinclair/typebox/compiler';
5
+ import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodType, z, ZodTypeAny, ZodNever, ZodUnknown } from 'zod';
6
+
7
+ /**
8
+ * Represents a catch-all schema type.
9
+ */
10
+ type TCatchall = TSchema;
11
+ /**
12
+ * Represents the shape of an object schema.
13
+ */
14
+ type TObjectShape = TProperties;
15
+ /**
16
+ * Represents an object schema type. If the type T is an object shape, it will return the original TObject type of T. Otherwise, it returns TNever.
17
+ *
18
+ * @template T - The type to check and possibly convert to an object schema.
19
+ */
20
+ type TObject<T> = T extends TObjectShape ? TObject$1<T> : TNever;
21
+ /**
22
+ * Translates a schema type T to its static type if T extends TCatchall. Otherwise, it returns TNever.
23
+ *
24
+ * @template T - The schema type to translate.
25
+ */
26
+ type TSchemaTranslate<T> = T extends TCatchall ? StaticDecode<T> : TNever;
27
+ /**
28
+ * Represents an unboxed object schema where each key can have an idiomatic schema.
29
+ */
30
+ type UnboxedTObjectSchema = {
31
+ [key: KeyTypes]: TIdiomaticSchema;
32
+ };
33
+ /**
34
+ * Represents an idiomatic schema which can be an unboxed object schema or a literal schema.
35
+ */
36
+ type TIdiomaticSchema = UnboxedTObjectSchema | LiteralSchema;
37
+ /**
38
+ * Represents a container for a union of idiomatic schemas.
39
+ */
40
+ type TUnionContainer = [...TIdiomaticSchema[]];
41
+ /**
42
+ * Resolves a union container to a tuple of resolved idiomatic schemas.
43
+ *
44
+ * @template T - The union container to resolve.
45
+ */
46
+ type UnionTResolve<T extends TUnionContainer> = T extends (infer UnionTypes)[] ? [TResolve<UnionTypes>] : TNever;
47
+ /**
48
+ * Resolves a schema type T to its resolved type. The depth is limited to 12 to prevent infinite recursion, due to StaticDecode limitations.
49
+ *
50
+ * @template T - The schema type to resolve.
51
+ * @template Depth - The current depth of the resolution.
52
+ */
53
+ type TResolve<T, Depth extends number = 0> = Depth extends 12 ? TUnknown : T extends LiteralSchema ? TLiteral<T> : T extends TSchema ? T : T extends TKind ? T : T extends TObject<TObjectShape> ? T : T extends UnboxedTObjectSchema ? TObject<{
54
+ [K in keyof T]: TResolve<T[K], Increment<Depth>>;
55
+ }> : T extends TypeCheck<infer Type> ? TResolve<Type, Increment<Depth>> : TNever;
56
+
57
+ /**
58
+ * This module provides a Zod-based schema definition.
59
+ * It includes various types, schema creation, validation, and OpenAPI integration.
60
+ *
61
+ * @module ZodSchemaValidator
62
+ */
63
+
64
+ /**
65
+ * Class representing a Zod schema definition.
66
+ * @implements {StaticSchemaValidator}
67
+ */
68
+ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T>), <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodOptional<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodArray<ZodResolve<T>>, <T extends ZodUnionContainer>(schemas: T) => ZodUnion<UnionZodResolve<T>>, <T extends LiteralSchema>(value: T) => ZodLiteral<ZodResolve<T>>, <T extends LiteralSchema>(schemaEnum: Record<string, T>) => ZodUnion<UnionZodResolve<[T, T, ...T[]]>>, (value: unknown) => value is ZodType, <T extends ZodCatchall>(schema: T, value: unknown) => boolean, <T extends ZodCatchall>(schema: T, value: unknown) => ParseResult<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => SchemaObject> {
69
+ _Type: 'Zod';
70
+ _SchemaCatchall: ZodType;
71
+ _ValidSchemaObject: ZodObject$1<ZodRawShape> | ZodArray<ZodObject$1<ZodRawShape>>;
72
+ string: z.ZodString;
73
+ uuid: z.ZodString;
74
+ email: z.ZodString;
75
+ uri: z.ZodString;
76
+ number: z.ZodNumber;
77
+ bigint: z.ZodBigInt;
78
+ boolean: z.ZodEffects<z.ZodBoolean, boolean, unknown>;
79
+ date: z.ZodDate;
80
+ symbol: z.ZodSymbol;
81
+ nullish: ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodUndefined]>;
82
+ any: z.ZodAny;
83
+ unknown: z.ZodUnknown;
84
+ never: z.ZodNever;
85
+ /**
86
+ * Pretty print Zod errors.
87
+ *
88
+ * @param {ZodError} error - The Zod error to pretty print.
89
+ * @returns
90
+ */
91
+ private prettyPrintZodErrors;
92
+ /**
93
+ * Compiles schema if this exists, for optimal performance.
94
+ *
95
+ * @param {ZodObject<ZodRawShape>} schema - The schema to compile.
96
+ * @returns {ZodResolve<T>} - The compiled schema.
97
+ */
98
+ compile<T extends ZodObject$1<ZodRawShape>>(schema: T): ZodResolve<T>;
99
+ /**
100
+ * Convert a schema to a Zod schema.
101
+ * @param {ZodIdiomaticSchema} schema - The schema to convert.
102
+ * @returns {ZodResolve<T>} The resolved schema.
103
+ */
104
+ schemify<T extends ZodIdiomaticSchema>(schema: T): ZodResolve<T>;
105
+ /**
106
+ * Make a schema optional.
107
+ * @param {ZodIdiomaticSchema} schema - The schema to make optional.
108
+ * @returns {ZodOptional<ZodResolve<T>>} The optional schema.
109
+ */
110
+ optional<T extends ZodIdiomaticSchema>(schema: T): ZodOptional<ZodResolve<T>>;
111
+ /**
112
+ * Create an array schema.
113
+ * @param {ZodIdiomaticSchema} schema - The schema to use for array items.
114
+ * @returns {ZodArray<ZodResolve<T>>} The array schema.
115
+ */
116
+ array<T extends ZodIdiomaticSchema>(schema: T): ZodArray<ZodResolve<T>>;
117
+ /**
118
+ * Create a union schema.
119
+ * @param {ZodUnionContainer} schemas - The schemas to union.
120
+ * @returns {ZodUnion<UnionZodResolve<T>>} The union schema.
121
+ */
122
+ union<T extends ZodUnionContainer>(schemas: T): ZodUnion<UnionZodResolve<T>>;
123
+ /**
124
+ * Create a literal schema.
125
+ * @param {LiteralSchema} value - The literal value.
126
+ * @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
127
+ */
128
+ literal<T extends LiteralSchema>(value: T): ZodLiteral<ZodResolve<T>>;
129
+ /**
130
+ * Create an enum schema.
131
+ * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
132
+ * @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
133
+ */
134
+ enum_<T extends LiteralSchema>(schemaEnum: Record<string, T>): ZodUnion<UnionZodResolve<[T, T, ...T[]]>>;
135
+ /**
136
+ * Checks if a value is a Zod schema.
137
+ * @param {unknown} value - The value to check.
138
+ * @returns {boolean} True if the value is a Zod schema.
139
+ */
140
+ isSchema(value: unknown): value is ZodType;
141
+ /**
142
+ * Validate a value against a schema.
143
+ * @param {ZodCatchall} schema - The schema to validate against.
144
+ * @param {unknown} value - The value to validate.
145
+ * @returns {boolean} True if valid, otherwise false.
146
+ */
147
+ validate<T extends ZodCatchall>(schema: T, value: unknown): boolean;
148
+ /**
149
+ * Parses a value to a schema validation.
150
+ *
151
+ * @param {ZodCatchall} schema - The schema to validate against.
152
+ * @param {unknown} value - The value to validate.
153
+ * @returns {ParseResult} - The discrimintated parsed value if successful, the error if unsuccessful.
154
+ */
155
+ parse<T extends ZodCatchall>(schema: T, value: unknown): ParseResult<ZodResolve<T>>;
156
+ /**
157
+ * Convert a schema to an OpenAPI schema object.
158
+ * @param {ZodIdiomaticSchema} schema - The schema to convert.
159
+ * @returns {SchemaObject} The OpenAPI schema object.
160
+ */
161
+ openapi<T extends ZodIdiomaticSchema>(schema: T): SchemaObject;
162
+ }
163
+
164
+ /**
165
+ * Represents a catch-all Zod schema type.
166
+ */
167
+ type ZodCatchall = ZodTypeAny;
168
+ /**
169
+ * Represents the shape of a Zod object schema.
170
+ */
171
+ type ZodObjectShape = ZodRawShape;
172
+ /**
173
+ * Represents a Zod object schema type. If the type T is a Zod object shape, it will return the original ZodObject type of T. Otherwise, it returns ZodNever.
174
+ *
175
+ * @template T - The type to check and possibly convert to a Zod object schema.
176
+ */
177
+ type ZodObject<T> = T extends ZodObjectShape ? ZodObject$1<T> : ZodNever;
178
+ /**
179
+ * Translates a Zod schema type T to its static type if T extends ZodCatchall. Otherwise, it returns ZodNever.
180
+ *
181
+ * @template T - The Zod schema type to translate.
182
+ */
183
+ type ZodSchemaTranslate<T> = T extends ZodCatchall ? z.infer<T> : ZodNever;
184
+ /**
185
+ * Represents an unboxed Zod object schema where each key can have an idiomatic schema.
186
+ */
187
+ type ZodObjectSchema = UnboxedObjectSchema<ZodSchemaValidator>;
188
+ /**
189
+ * Represents an idiomatic schema for Zod which can be an unboxed object schema or a literal schema.
190
+ */
191
+ type ZodIdiomaticSchema = IdiomaticSchema<ZodSchemaValidator>;
192
+ /**
193
+ * Represents a container for a union of Zod idiomatic schemas.
194
+ */
195
+ type ZodUnionContainer = readonly [
196
+ ZodIdiomaticSchema,
197
+ ZodIdiomaticSchema,
198
+ ...ZodIdiomaticSchema[]
199
+ ];
200
+ /**
201
+ * Resolves a union container to a tuple of resolved Zod idiomatic schemas.
202
+ *
203
+ * @template T - The union container to resolve.
204
+ */
205
+ type UnionZodResolve<T extends ZodUnionContainer> = T extends [
206
+ infer A extends ZodIdiomaticSchema,
207
+ infer B extends ZodIdiomaticSchema,
208
+ ...infer C extends ZodIdiomaticSchema[]
209
+ ] ? [
210
+ ZodResolve<A>,
211
+ ZodResolve<B>,
212
+ ...{
213
+ [K in keyof C]: ZodResolve<C[K]>;
214
+ }
215
+ ] : [ZodNever, ZodNever];
216
+ /**
217
+ * Resolves a Zod schema type T to its resolved type. The depth is limited to 31 to prevent infinite recursion.
218
+ *
219
+ * @template T - The Zod schema type to resolve.
220
+ * @template Depth - The current depth of the resolution.
221
+ */
222
+ type ZodResolve<T, Depth extends number = 0> = Depth extends 31 ? ZodUnknown : T extends LiteralSchema ? ZodLiteral<T> : T extends ZodType ? T : T extends ZodObjectSchema ? ZodObject<{
223
+ [K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
224
+ }> : ZodNever;
225
+
226
+ /**
227
+ * The result associated with an attempted parsing.
228
+ *
229
+ */
230
+ type ParseResult<T> = {
231
+ ok: true;
232
+ value: T;
233
+ } | {
234
+ ok: false;
235
+ error?: string;
236
+ };
237
+ /**
238
+ * Interface representing a schema validator.
239
+ *
240
+ * @template SchematicFunction - The function type for schemifying a schema.
241
+ * @template OptionalFunction - The function type for making a schema optional.
242
+ * @template ArrayFunction - The function type for converting a schema into an array.
243
+ * @template UnionFunction - The function type for unionizing multiple schemas.
244
+ * @template LiteralFunction - The function type for creating a literal schema.
245
+ * @template ValidationFunction - The function type for validating a value against a schema.
246
+ * @template ParseFunction - The function type for parsing a value against a schema.
247
+ * @template OpenAPIFunction - The function type for converting a schema into an OpenAPI schema object.
248
+ */
249
+ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
250
+ /**
251
+ * The type of the schema validator. Meant to be used with non-null assertions.
252
+ */
253
+ _Type: unknown;
254
+ /**
255
+ * The catch-all type for the schema. Meant to be used with non-null assertions.
256
+ */
257
+ _SchemaCatchall: unknown;
258
+ /**
259
+ * The valid schema object type. Meant to be used with non-null assertions.
260
+ */
261
+ _ValidSchemaObject: unknown;
262
+ /**
263
+ * Validator for string type.
264
+ */
265
+ string: unknown;
266
+ /**
267
+ * Validator for uuid type.
268
+ */
269
+ uuid: unknown;
270
+ /**
271
+ * Validator for uri type.
272
+ */
273
+ uri: unknown;
274
+ /**
275
+ * Validator for email type.
276
+ */
277
+ email: unknown;
278
+ /**
279
+ * Validator for number type.
280
+ */
281
+ number: unknown;
282
+ /**
283
+ * Validator for bigint type.
284
+ */
285
+ bigint: unknown;
286
+ /**
287
+ * Validator for boolean type.
288
+ */
289
+ boolean: unknown;
290
+ /**
291
+ * Validator for date type.
292
+ */
293
+ date: unknown;
294
+ /**
295
+ * Validator for symbol type.
296
+ */
297
+ symbol: unknown;
298
+ /**
299
+ * Validator for nullish type.
300
+ */
301
+ nullish: unknown;
302
+ /**
303
+ * Validator for any type.
304
+ */
305
+ any: unknown;
306
+ /**
307
+ * Validator for unknown type.
308
+ */
309
+ unknown: unknown;
310
+ /**
311
+ * Validator for never type.
312
+ */
313
+ never: unknown;
314
+ /**
315
+ * Compiles schema if this exists, for optimal performance.
316
+ *
317
+ * @param {T} schema - The schema to compile.
318
+ * @returns {unknown} - The compiled schema.
319
+ */
320
+ compile: CompilationFunction;
321
+ /**
322
+ * Converts a valid schema input into a schemified form.
323
+ *
324
+ * @param {T} schema - The schema to schemify.
325
+ * @returns {unknown} - The schemified form of the schema.
326
+ */
327
+ schemify: SchematicFunction;
328
+ /**
329
+ * Converts a schema into an optional schema.
330
+ *
331
+ * @param {T} schema - The schema to make optional.
332
+ * @returns {unknown} - The optional form of the schema.
333
+ */
334
+ optional: OptionalFunction;
335
+ /**
336
+ * Converts a schema into an array schema.
337
+ *
338
+ * @param {T} schema - The schema to convert into an array.
339
+ * @returns {unknown} - The array form of the schema.
340
+ */
341
+ array: ArrayFunction;
342
+ /**
343
+ * Converts multiple schemas into a union schema.
344
+ *
345
+ * @param {T[]} schemas - The schemas to unionize.
346
+ * @returns {unknown} - The union form of the schemas.
347
+ */
348
+ union: UnionFunction;
349
+ /**
350
+ * Creates a literal schema from a value.
351
+ *
352
+ * @param {T} value - The literal value.
353
+ * @returns {unknown} - The literal schema.
354
+ */
355
+ literal: LiteralFunction;
356
+ /**
357
+ * Creates an enum schema from a record of literal values.
358
+ *
359
+ * @param {Record<string, T>} schemaEnum - The enum schema.
360
+ * @returns {unknown} - The enum schema.
361
+ */
362
+ enum_: EnumFunction;
363
+ /**
364
+ * Checks if a value is a schema.
365
+ *
366
+ * @param {unknown} value - The value to check.
367
+ * @returns {boolean} - Whether the value is a schema.
368
+ */
369
+ isSchema: SchemaGuardFunction;
370
+ /**
371
+ * Validates a value against a schema.
372
+ *
373
+ * @param {T} schema - The schema to validate against.
374
+ * @param {unknown} value - The value to validate.
375
+ * @returns {boolean} - Whether the value is valid according to the schema.
376
+ */
377
+ validate: ValidationFunction;
378
+ /**
379
+ * Parses a value to a schema validation.
380
+ *
381
+ * @param {T} schema - The schema to validate against.
382
+ * @param {unknown} value - The value to validate.
383
+ * @returns {ParseResult} - The discrimintated parsed value if successful, the error if unsuccessful.
384
+ */
385
+ parse: ParseFunction;
386
+ /**
387
+ * Converts a schema into an OpenAPI schema object.
388
+ *
389
+ * @param {T} schema - The schema to convert.
390
+ * @returns {SchemaObject} - The OpenAPI schema object.
391
+ */
392
+ openapi: OpenAPIFunction;
393
+ }
394
+ /**
395
+ * Type representing any schema validator.
396
+ */
397
+ type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
398
+ /**
399
+ * The type of the schema resolver.
400
+ */
401
+ _Type: keyof SchemaResolve<unknown>;
402
+ };
403
+ /**
404
+ * Interface representing schema resolution for different validation libraries.
405
+ *
406
+ * @template T - The type of the schema to resolve.
407
+ */
408
+ interface SchemaResolve<T> {
409
+ /**
410
+ * Schema resolution for Zod.
411
+ */
412
+ Zod: ZodResolve<T>;
413
+ /**
414
+ * Schema resolution for TypeBox.
415
+ */
416
+ TypeBox: TResolve<T>;
417
+ }
418
+ /**
419
+ * Interface representing schema translation for different validation libraries.
420
+ *
421
+ * @template T - The type of the schema to translate.
422
+ */
423
+ interface SchemaTranslate<T> {
424
+ /**
425
+ * Schema translation for Zod.
426
+ */
427
+ Zod: ZodSchemaTranslate<T>;
428
+ /**
429
+ * Schema translation for TypeBox.
430
+ */
431
+ TypeBox: TSchemaTranslate<T>;
432
+ }
433
+ /**
434
+ * Type representing the prettified schema translation.
435
+ *
436
+ * @template T - The type of the schema to translate.
437
+ * @template SV - The type of the schema validator.
438
+ */
439
+ type SchemaPrettify<T, SV extends AnySchemaValidator> = Prettify<SchemaTranslate<T>[SV['_Type']]>;
440
+ /**
441
+ * Type representing a schema, which can be a valid schema object or an idiomatic schema.
442
+ *
443
+ * @template T - The type of the schema.
444
+ * @template SV - The type of the schema validator.
445
+ */
446
+ type Schema<T extends SV['_ValidSchemaObject'] | IdiomaticSchema<SV>, SV extends AnySchemaValidator> = SchemaPrettify<SchemaResolve<T>[SV['_Type']], SV>;
447
+ /**
448
+ * Represents a schema for an unboxed object where each key can have an idiomatic schema.
449
+ *
450
+ * @template SV - The type of the schema validator.
451
+ */
452
+ type UnboxedObjectSchema<SV extends AnySchemaValidator> = {
453
+ [key: KeyTypes]: IdiomaticSchema<SV>;
454
+ };
455
+ /**
456
+ * Represents a schema that can be a literal value.
457
+ */
458
+ type LiteralSchema = string | number | boolean;
459
+ /**
460
+ * Represents an idiomatic schema which can be an unboxed object schema, a literal schema, or a catch-all type.
461
+ *
462
+ * @template SV - The type of the schema validator.
463
+ */
464
+ type IdiomaticSchema<SV extends AnySchemaValidator> = LiteralSchema | SV['_SchemaCatchall'] | UnboxedObjectSchema<SV>;
465
+ /**
466
+ * Increments a number type by one, with support up to 50.
467
+ *
468
+ * @template T - The number type to increment.
469
+ */
470
+ type Increment<T extends number> = T extends 0 ? 1 : T extends 1 ? 2 : T extends 2 ? 3 : T extends 3 ? 4 : T extends 4 ? 5 : T extends 5 ? 6 : T extends 6 ? 7 : T extends 7 ? 8 : T extends 8 ? 9 : T extends 9 ? 10 : T extends 10 ? 11 : T extends 11 ? 12 : T extends 12 ? 13 : T extends 13 ? 14 : T extends 14 ? 15 : T extends 15 ? 16 : T extends 16 ? 17 : T extends 17 ? 18 : T extends 18 ? 19 : T extends 19 ? 20 : T extends 20 ? 21 : T extends 21 ? 22 : T extends 22 ? 23 : T extends 23 ? 24 : T extends 24 ? 25 : T extends 25 ? 26 : T extends 26 ? 27 : T extends 27 ? 28 : T extends 28 ? 29 : T extends 29 ? 30 : T extends 30 ? 31 : T extends 31 ? 32 : T extends 32 ? 33 : T extends 33 ? 34 : T extends 34 ? 35 : T extends 35 ? 36 : T extends 36 ? 37 : T extends 37 ? 38 : T extends 38 ? 39 : T extends 39 ? 40 : T extends 40 ? 41 : T extends 41 ? 42 : T extends 42 ? 43 : T extends 43 ? 44 : T extends 44 ? 45 : T extends 45 ? 46 : T extends 46 ? 47 : T extends 47 ? 48 : T extends 48 ? 49 : T extends 49 ? 50 : 50;
471
+ /**
472
+ * Represents key types that can be used in the schema.
473
+ */
474
+ type KeyTypes = string | number;
475
+
476
+ export { type AnySchemaValidator as A, type IdiomaticSchema as I, type KeyTypes as K, type LiteralSchema as L, type ParseResult as P, type SchemaValidator as S, type TObject as T, type UnionZodResolve as U, ZodSchemaValidator as Z, type ZodIdiomaticSchema as a, type ZodResolve as b, type ZodUnionContainer as c, type ZodCatchall as d, type TIdiomaticSchema as e, type TResolve as f, type TUnionContainer as g, type UnionTResolve as h, type SchemaResolve as i, type SchemaTranslate as j, type Schema as k, type UnboxedObjectSchema as l, type Increment as m };