@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,406 @@
1
+ // src/typebox/typeboxSchemaValidator.ts
2
+ import {
3
+ Kind,
4
+ KindGuard,
5
+ Type
6
+ } from "@sinclair/typebox";
7
+ import { TypeCheck, TypeCompiler } from "@sinclair/typebox/compiler";
8
+ import {
9
+ DefaultErrorFunction,
10
+ SetErrorFunction,
11
+ ValueErrorType
12
+ } from "@sinclair/typebox/errors";
13
+ import { Value } from "@sinclair/typebox/value";
14
+ SetErrorFunction((params) => {
15
+ switch (params.errorType) {
16
+ case ValueErrorType.Union:
17
+ case ValueErrorType.Array:
18
+ case ValueErrorType.String:
19
+ case ValueErrorType.Number:
20
+ return params.schema.errorType ? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? "s" : ""}` : DefaultErrorFunction(params);
21
+ default:
22
+ return DefaultErrorFunction(params);
23
+ }
24
+ });
25
+ var TypeboxSchemaValidator = class {
26
+ _Type;
27
+ _SchemaCatchall;
28
+ _ValidSchemaObject;
29
+ string = Type.String();
30
+ // uuid = Type.String({ format: 'uuid' });
31
+ uuid = Type.String({
32
+ pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
33
+ errorType: "uuid"
34
+ });
35
+ uri = Type.String({
36
+ pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
37
+ errorType: "uri"
38
+ });
39
+ email = Type.String({
40
+ pattern: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
41
+ errorType: "email"
42
+ });
43
+ number = Type.Transform(
44
+ Type.Union(
45
+ [
46
+ Type.Number(),
47
+ Type.String({ pattern: "^[0-9]+$" }),
48
+ Type.Boolean(),
49
+ Type.Null(),
50
+ Type.Date(),
51
+ Type.BigInt()
52
+ ],
53
+ {
54
+ errorType: "number-like",
55
+ openapiType: Type.Number()
56
+ }
57
+ )
58
+ ).Decode((value) => {
59
+ if (typeof value !== "number") {
60
+ const num = Number(value);
61
+ if (isNaN(num)) {
62
+ throw new Error("Invalid number");
63
+ } else {
64
+ return num;
65
+ }
66
+ }
67
+ return value;
68
+ }).Encode(Number);
69
+ bigint = Type.Transform(
70
+ Type.Union(
71
+ [
72
+ Type.BigInt(),
73
+ Type.Number(),
74
+ Type.String({ pattern: "^[0-9]+$" }),
75
+ Type.Boolean(),
76
+ Type.Date()
77
+ ],
78
+ {
79
+ errorType: "BigInt-like",
80
+ openapiType: Type.BigInt()
81
+ }
82
+ )
83
+ ).Decode((value) => {
84
+ if (typeof value !== "bigint") {
85
+ try {
86
+ return BigInt(value instanceof Date ? value.getTime() : value);
87
+ } catch {
88
+ throw new Error("Invalid bigint");
89
+ }
90
+ }
91
+ return value;
92
+ }).Encode(BigInt);
93
+ boolean = Type.Transform(
94
+ Type.Union(
95
+ [
96
+ Type.Boolean(),
97
+ Type.String({
98
+ pattern: "^(t|T)(r|R)(u|U)(e|E)$|^(f|F)(a|A)(l|L)(s|S)(e|E)$"
99
+ })
100
+ ],
101
+ {
102
+ errorType: "boolean-like",
103
+ openapiType: Type.Boolean()
104
+ }
105
+ )
106
+ ).Decode((value) => {
107
+ if (typeof value === "string") {
108
+ if (value.toLowerCase() === "true") return true;
109
+ if (value.toLowerCase() === "false") return false;
110
+ } else {
111
+ return value;
112
+ }
113
+ }).Encode(Boolean);
114
+ date = Type.Transform(
115
+ Type.Union(
116
+ [
117
+ Type.Date(),
118
+ Type.Number(),
119
+ Type.String({
120
+ pattern: "^\\d{4}(-\\d{2}){0,2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(Z|([+-]\\d{2}:\\d{2}))?)?$|^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$|^\\d{4}\\/\\d{1,2}\\/\\d{1,2}$|^\\d+$"
121
+ }),
122
+ Type.Boolean(),
123
+ Type.Null()
124
+ ],
125
+ {
126
+ errorType: "date",
127
+ openapiType: Type.Date()
128
+ }
129
+ )
130
+ ).Decode((value) => {
131
+ if (!(value instanceof Date)) {
132
+ if (value === null || typeof value === "boolean") {
133
+ return /* @__PURE__ */ new Date(value ? 1 : 0);
134
+ }
135
+ return new Date(value);
136
+ }
137
+ return value;
138
+ }).Encode((value) => new Date(value));
139
+ symbol = Type.Symbol();
140
+ nullish = Type.Union([Type.Void(), Type.Null(), Type.Undefined()], {
141
+ errorType: "nullish"
142
+ });
143
+ any = Type.Any();
144
+ unknown = Type.Unknown();
145
+ never = Type.Never();
146
+ /**
147
+ * Extracts the error type of a schema for error messages.
148
+ *
149
+ * @param {TCatchall} schema - A schema that contains some type information.
150
+ * @returns The type of the schema for error messages.
151
+ */
152
+ errorType(schema) {
153
+ if (Object.hasOwn(schema, "errorType")) {
154
+ return schema.errorType;
155
+ } else if (KindGuard.IsLiteral(schema)) {
156
+ return schema.const;
157
+ }
158
+ return schema[Kind].toLowerCase();
159
+ }
160
+ /**
161
+ * Pretty print TypeBox errors.
162
+ *
163
+ * @param {ValueError[]} errors
164
+ * @returns
165
+ */
166
+ prettyPrintTypeBoxErrors(errors) {
167
+ if (!errors || errors.length === 0) return;
168
+ const errorMessages = errors.map((err, index) => {
169
+ const path = err.path.length > 0 ? err.path.split("/").slice(1).join(" > ") : "root";
170
+ return `${index + 1}. Path: ${path}
171
+ Message: ${err.message}`;
172
+ });
173
+ return `Validation failed with the following errors:
174
+ ${errorMessages.join("\n\n")}`;
175
+ }
176
+ /**
177
+ * Compiles schema if this exists, for optimal performance.
178
+ *
179
+ * @param {TObject<TProperties>} schema - The schema to compile.
180
+ * @returns {TypeCheck<T>} - The compiled schema.
181
+ */
182
+ compile(schema) {
183
+ return TypeCompiler.Compile(schema);
184
+ }
185
+ /**
186
+ * Convert a schema to a TypeBox schema.
187
+ * @param {TIdiomaticSchema} schema - The schema to convert.
188
+ * @returns {TResolve<T>} The resolved schema.
189
+ */
190
+ schemify(schema) {
191
+ if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
192
+ return Type.Literal(schema);
193
+ }
194
+ if (KindGuard.IsSchema(schema) || schema instanceof TypeCheck) {
195
+ return schema;
196
+ }
197
+ const newSchema = {};
198
+ Object.getOwnPropertyNames(schema).forEach((key) => {
199
+ if (KindGuard.IsSchema(schema[key])) {
200
+ newSchema[key] = schema[key];
201
+ } else {
202
+ const schemified = this.schemify(schema[key]);
203
+ newSchema[key] = schemified;
204
+ }
205
+ });
206
+ return Type.Object(newSchema);
207
+ }
208
+ /**
209
+ * Make a schema optional.
210
+ * @param {TIdiomaticSchema} schema - The schema to make optional.
211
+ * @returns {TOptional<TResolve<T>>} The optional schema.
212
+ */
213
+ optional(schema) {
214
+ const schemified = KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
215
+ return Type.Optional(schemified);
216
+ }
217
+ /**
218
+ * Create an array schema.
219
+ * @param {TIdiomaticSchema} schema - The schema to use for array items.
220
+ * @returns {TArray<TResolve<T>>} The array schema.
221
+ */
222
+ array(schema) {
223
+ const schemified = KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
224
+ return Type.Array(schemified, {
225
+ errorType: `array of ${this.errorType(schemified)}`
226
+ });
227
+ }
228
+ /**
229
+ * Create a union schema.
230
+ * @param {TUnionContainer} schemas - The schemas to union.
231
+ * @returns {TUnion<UnionTResolve<T>>} The union schema.
232
+ *
233
+ * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
234
+ * This is a limitation of TypeBox. Consider using "optional" instead.
235
+ */
236
+ union(schemas) {
237
+ const unionTypes = schemas.map((schema) => {
238
+ return KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
239
+ });
240
+ return Type.Union(unionTypes, {
241
+ errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(", ")}`,
242
+ errorSuffix: true
243
+ });
244
+ }
245
+ /**
246
+ * Create a literal schema.
247
+ * @param {LiteralSchema} value - The literal value.
248
+ * @returns {TLiteral<T>} The literal schema.
249
+ */
250
+ literal(value) {
251
+ return Type.Literal(value, {
252
+ errorType: value
253
+ });
254
+ }
255
+ /**
256
+ * Create an enum schema.
257
+ * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
258
+ * @returns {TUnion<UnionTResolve<T[]>>} The enum schema.
259
+ */
260
+ enum_(schemaEnum) {
261
+ return this.union(Object.values(schemaEnum));
262
+ }
263
+ /**
264
+ * Check if a value is a TypeBox object schema.
265
+ * @param {unknown} value - The value to check.
266
+ * @returns {boolean} True if the value is a TypeBox object schema.
267
+ */
268
+ isSchema(value) {
269
+ return KindGuard.IsSchema(value);
270
+ }
271
+ /**
272
+ * Validate a value against a schema.
273
+ *
274
+ * @param {TSchema} schema - The schema to validate against.
275
+ * @param {unknown} value - The value to validate.
276
+ * @returns {boolean} True if valid, otherwise false.
277
+ */
278
+ validate(schema, value) {
279
+ if (schema instanceof TypeCheck) {
280
+ return schema.Check(value);
281
+ } else {
282
+ const schemified = KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
283
+ return Value.Check(schemified, value);
284
+ }
285
+ }
286
+ /**
287
+ * Parse a value against a schema.
288
+ *
289
+ * @param {TSchema} schema - The schema to validate against.
290
+ * @param {unknown} value - The value to validate.
291
+ * @returns {ParseResult<TResolve<T>>} The parsing result.
292
+ */
293
+ parse(schema, value) {
294
+ let errors = [];
295
+ let conversion;
296
+ if (schema instanceof TypeCheck) {
297
+ if (schema.Check(value)) {
298
+ conversion = schema.Decode(value);
299
+ } else {
300
+ errors = Array.from(schema.Errors(value));
301
+ }
302
+ } else {
303
+ const schemified = KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
304
+ if (Value.Check(schemified, value)) {
305
+ conversion = Value.Decode(schemified, value);
306
+ } else {
307
+ errors = Array.from(Value.Errors(schemified, value));
308
+ }
309
+ }
310
+ return errors != null && errors.length === 0 ? {
311
+ ok: true,
312
+ value: conversion
313
+ } : {
314
+ ok: false,
315
+ error: this.prettyPrintTypeBoxErrors(errors)
316
+ };
317
+ }
318
+ /**
319
+ * Convert a schema to an OpenAPI schema object.
320
+ * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
321
+ * @returns {SchemaObject} The OpenAPI schema object.
322
+ */
323
+ openapi(schema) {
324
+ const schemified = KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
325
+ if (Object.hasOwn(schemified, "openapiType") || KindGuard.IsLiteral(schemified)) {
326
+ return schemified.openapiType;
327
+ }
328
+ const newSchema = Object.assign({}, schemified);
329
+ if (Object.hasOwn(newSchema, "properties")) {
330
+ newSchema.properties = { ...schemified.properties };
331
+ if (newSchema.properties) {
332
+ Object.entries(newSchema.properties).forEach(([key, value]) => {
333
+ if (KindGuard.IsSchema(value) && newSchema.properties) {
334
+ newSchema.properties[key] = this.openapi(value);
335
+ }
336
+ });
337
+ }
338
+ }
339
+ return newSchema;
340
+ }
341
+ };
342
+
343
+ // src/typebox/staticSchemaValidator.ts
344
+ var SchemaValidator = () => new TypeboxSchemaValidator();
345
+ var StaticSchemaValidator = SchemaValidator();
346
+ var string = StaticSchemaValidator.string;
347
+ var uuid = StaticSchemaValidator.uuid;
348
+ var uri = StaticSchemaValidator.uri;
349
+ var email = StaticSchemaValidator.email;
350
+ var number = StaticSchemaValidator.number;
351
+ var bigint = StaticSchemaValidator.bigint;
352
+ var boolean = StaticSchemaValidator.boolean;
353
+ var date = StaticSchemaValidator.date;
354
+ var symbol = StaticSchemaValidator.symbol;
355
+ var nullish = StaticSchemaValidator.nullish;
356
+ var any = StaticSchemaValidator.any;
357
+ var unknown = StaticSchemaValidator.unknown;
358
+ var never = StaticSchemaValidator.never;
359
+ var schemify = StaticSchemaValidator.schemify.bind(
360
+ StaticSchemaValidator
361
+ );
362
+ var optional = StaticSchemaValidator.optional.bind(
363
+ StaticSchemaValidator
364
+ );
365
+ var array = StaticSchemaValidator.array.bind(StaticSchemaValidator);
366
+ var union = StaticSchemaValidator.union.bind(StaticSchemaValidator);
367
+ var literal = StaticSchemaValidator.literal.bind(
368
+ StaticSchemaValidator
369
+ );
370
+ var enum_ = StaticSchemaValidator.enum_.bind(StaticSchemaValidator);
371
+ var isSchema = StaticSchemaValidator.isSchema.bind(
372
+ StaticSchemaValidator
373
+ );
374
+ var validate = StaticSchemaValidator.validate.bind(
375
+ StaticSchemaValidator
376
+ );
377
+ var parse = StaticSchemaValidator.parse.bind(StaticSchemaValidator);
378
+ var openapi = StaticSchemaValidator.openapi.bind(
379
+ StaticSchemaValidator
380
+ );
381
+ export {
382
+ SchemaValidator,
383
+ any,
384
+ array,
385
+ bigint,
386
+ boolean,
387
+ date,
388
+ email,
389
+ enum_,
390
+ isSchema,
391
+ literal,
392
+ never,
393
+ nullish,
394
+ number,
395
+ openapi,
396
+ optional,
397
+ parse,
398
+ schemify,
399
+ string,
400
+ symbol,
401
+ union,
402
+ unknown,
403
+ uri,
404
+ uuid,
405
+ validate
406
+ };
@@ -0,0 +1,106 @@
1
+ import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
+ import { Z as ZodSchemaValidator, a as ZodIdiomaticSchema, b as ZodResolve, c as ZodUnionContainer, U as UnionZodResolve, L as LiteralSchema, d as ZodCatchall, P as ParseResult } from '../../index-V6qNDTlr.mjs';
3
+ import * as zod from 'zod';
4
+ import '@forklaunch/common';
5
+ import '@sinclair/typebox';
6
+ import '@sinclair/typebox/compiler';
7
+
8
+ /**
9
+ * Factory function for creating a ZodSchemaValidator instance.
10
+ * @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
11
+ */
12
+ declare const SchemaValidator: () => ZodSchemaValidator;
13
+ /**
14
+ * Zod schema definition for string type.
15
+ */
16
+ declare const string: zod.ZodString;
17
+ /**
18
+ * Zod schema definition for UUID type.
19
+ */
20
+ declare const uuid: zod.ZodString;
21
+ /**
22
+ * Zod schema definition for email type.
23
+ */
24
+ declare const email: zod.ZodString;
25
+ /**
26
+ * Zod schema definition for URI type.
27
+ */
28
+ declare const uri: zod.ZodString;
29
+ /**
30
+ * Zod schema definition for number type.
31
+ */
32
+ declare const number: zod.ZodNumber;
33
+ /**
34
+ * Zod schema definition for bigint type.
35
+ */
36
+ declare const bigint: zod.ZodBigInt;
37
+ /**
38
+ * Zod schema definition for boolean type.
39
+ */
40
+ declare const boolean: zod.ZodEffects<zod.ZodBoolean, boolean, unknown>;
41
+ /**
42
+ * Zod schema definition for date type.
43
+ */
44
+ declare const date: zod.ZodDate;
45
+ /**
46
+ * Zod schema definition for symbol type.
47
+ */
48
+ declare const symbol: zod.ZodSymbol;
49
+ /**
50
+ * Zod schema definition for undefined, null, void types.
51
+ */
52
+ declare const nullish: zod.ZodUnion<[zod.ZodVoid, zod.ZodNull, zod.ZodUndefined]>;
53
+ /**
54
+ * Zod schema definition for any type.
55
+ */
56
+ declare const any: zod.ZodAny;
57
+ /**
58
+ * Zod schema definition for unknown type.
59
+ */
60
+ declare const unknown: zod.ZodUnknown;
61
+ /**
62
+ * Zod schema definition for never type.
63
+ */
64
+ declare const never: zod.ZodNever;
65
+ /**
66
+ * Transforms valid schema into Zod schema.
67
+ */
68
+ declare const schemify: <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>;
69
+ /**
70
+ * Makes a valid schema optional.
71
+ */
72
+ declare const optional: <T extends ZodIdiomaticSchema>(schema: T) => zod.ZodOptional<ZodResolve<T>>;
73
+ /**
74
+ * Defines an array for a valid schema.
75
+ */
76
+ declare const array: <T extends ZodIdiomaticSchema>(schema: T) => zod.ZodArray<ZodResolve<T>>;
77
+ /**
78
+ * Defines a union for a valid schema.
79
+ */
80
+ declare const union: <T extends ZodUnionContainer>(schemas: T) => zod.ZodUnion<UnionZodResolve<T>>;
81
+ /**
82
+ * Defines a literal for a valid schema.
83
+ */
84
+ declare const literal: <T extends LiteralSchema>(value: T) => zod.ZodLiteral<ZodResolve<T>>;
85
+ /**
86
+ * Defines an enum for a valid schema.
87
+ */
88
+ declare const enum_: <T extends LiteralSchema>(schemaEnum: Record<string, T>) => zod.ZodUnion<UnionZodResolve<[T, T, ...T[]]>>;
89
+ /**
90
+ * Checks if a value is a Zod schema.
91
+ */
92
+ declare const isSchema: (value: unknown) => value is zod.ZodSchema;
93
+ /**
94
+ * Validates a value against a valid schema.
95
+ */
96
+ declare const validate: <T extends ZodCatchall>(schema: T, value: unknown) => boolean;
97
+ /**
98
+ * Parses a value to be conformant to a particular schema.
99
+ */
100
+ declare const parse: <T extends ZodCatchall>(schema: T, value: unknown) => ParseResult<ZodResolve<T>>;
101
+ /**
102
+ * Generates an OpenAPI schema object from a valid schema.
103
+ */
104
+ declare const openapi: <T extends ZodIdiomaticSchema>(schema: T) => openapi3_ts_oas31.SchemaObject;
105
+
106
+ export { SchemaValidator, ZodSchemaValidator, any, array, bigint, boolean, date, email, enum_, isSchema, literal, never, nullish, number, openapi, optional, parse, schemify, string, symbol, union, unknown, uri, uuid, validate };
@@ -1,3 +1,106 @@
1
- export * from './staticSchemaValidator';
2
- export type { ZodSchemaValidator } from './zodSchemaValidator';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
+ import { Z as ZodSchemaValidator, a as ZodIdiomaticSchema, b as ZodResolve, c as ZodUnionContainer, U as UnionZodResolve, L as LiteralSchema, d as ZodCatchall, P as ParseResult } from '../../index-V6qNDTlr.js';
3
+ import * as zod from 'zod';
4
+ import '@forklaunch/common';
5
+ import '@sinclair/typebox';
6
+ import '@sinclair/typebox/compiler';
7
+
8
+ /**
9
+ * Factory function for creating a ZodSchemaValidator instance.
10
+ * @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
11
+ */
12
+ declare const SchemaValidator: () => ZodSchemaValidator;
13
+ /**
14
+ * Zod schema definition for string type.
15
+ */
16
+ declare const string: zod.ZodString;
17
+ /**
18
+ * Zod schema definition for UUID type.
19
+ */
20
+ declare const uuid: zod.ZodString;
21
+ /**
22
+ * Zod schema definition for email type.
23
+ */
24
+ declare const email: zod.ZodString;
25
+ /**
26
+ * Zod schema definition for URI type.
27
+ */
28
+ declare const uri: zod.ZodString;
29
+ /**
30
+ * Zod schema definition for number type.
31
+ */
32
+ declare const number: zod.ZodNumber;
33
+ /**
34
+ * Zod schema definition for bigint type.
35
+ */
36
+ declare const bigint: zod.ZodBigInt;
37
+ /**
38
+ * Zod schema definition for boolean type.
39
+ */
40
+ declare const boolean: zod.ZodEffects<zod.ZodBoolean, boolean, unknown>;
41
+ /**
42
+ * Zod schema definition for date type.
43
+ */
44
+ declare const date: zod.ZodDate;
45
+ /**
46
+ * Zod schema definition for symbol type.
47
+ */
48
+ declare const symbol: zod.ZodSymbol;
49
+ /**
50
+ * Zod schema definition for undefined, null, void types.
51
+ */
52
+ declare const nullish: zod.ZodUnion<[zod.ZodVoid, zod.ZodNull, zod.ZodUndefined]>;
53
+ /**
54
+ * Zod schema definition for any type.
55
+ */
56
+ declare const any: zod.ZodAny;
57
+ /**
58
+ * Zod schema definition for unknown type.
59
+ */
60
+ declare const unknown: zod.ZodUnknown;
61
+ /**
62
+ * Zod schema definition for never type.
63
+ */
64
+ declare const never: zod.ZodNever;
65
+ /**
66
+ * Transforms valid schema into Zod schema.
67
+ */
68
+ declare const schemify: <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>;
69
+ /**
70
+ * Makes a valid schema optional.
71
+ */
72
+ declare const optional: <T extends ZodIdiomaticSchema>(schema: T) => zod.ZodOptional<ZodResolve<T>>;
73
+ /**
74
+ * Defines an array for a valid schema.
75
+ */
76
+ declare const array: <T extends ZodIdiomaticSchema>(schema: T) => zod.ZodArray<ZodResolve<T>>;
77
+ /**
78
+ * Defines a union for a valid schema.
79
+ */
80
+ declare const union: <T extends ZodUnionContainer>(schemas: T) => zod.ZodUnion<UnionZodResolve<T>>;
81
+ /**
82
+ * Defines a literal for a valid schema.
83
+ */
84
+ declare const literal: <T extends LiteralSchema>(value: T) => zod.ZodLiteral<ZodResolve<T>>;
85
+ /**
86
+ * Defines an enum for a valid schema.
87
+ */
88
+ declare const enum_: <T extends LiteralSchema>(schemaEnum: Record<string, T>) => zod.ZodUnion<UnionZodResolve<[T, T, ...T[]]>>;
89
+ /**
90
+ * Checks if a value is a Zod schema.
91
+ */
92
+ declare const isSchema: (value: unknown) => value is zod.ZodSchema;
93
+ /**
94
+ * Validates a value against a valid schema.
95
+ */
96
+ declare const validate: <T extends ZodCatchall>(schema: T, value: unknown) => boolean;
97
+ /**
98
+ * Parses a value to be conformant to a particular schema.
99
+ */
100
+ declare const parse: <T extends ZodCatchall>(schema: T, value: unknown) => ParseResult<ZodResolve<T>>;
101
+ /**
102
+ * Generates an OpenAPI schema object from a valid schema.
103
+ */
104
+ declare const openapi: <T extends ZodIdiomaticSchema>(schema: T) => openapi3_ts_oas31.SchemaObject;
105
+
106
+ export { SchemaValidator, ZodSchemaValidator, any, array, bigint, boolean, date, email, enum_, isSchema, literal, never, nullish, number, openapi, optional, parse, schemify, string, symbol, union, unknown, uri, uuid, validate };