@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
@@ -1,362 +0,0 @@
1
- /**
2
- * This module provides a TypeScript-based schema definition using the TypeBox library.
3
- * It includes various types, schema creation, validation, and OpenAPI integration.
4
- *
5
- * @module TypeboxSchemaValidator
6
- */
7
- import { Kind, KindGuard, Type } from '@sinclair/typebox';
8
- import { TypeCheck, TypeCompiler } from '@sinclair/typebox/compiler';
9
- import { DefaultErrorFunction, SetErrorFunction, ValueErrorType } from '@sinclair/typebox/errors';
10
- import { Value } from '@sinclair/typebox/value';
11
- /**
12
- * Typebox custom error function
13
- */
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
21
- ? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? 's' : ''}`
22
- : DefaultErrorFunction(params);
23
- default:
24
- return DefaultErrorFunction(params);
25
- }
26
- });
27
- /**
28
- * Class representing a TypeBox schema definition.
29
- * @implements {SchemaValidator}
30
- */
31
- export class TypeboxSchemaValidator {
32
- _Type;
33
- _SchemaCatchall;
34
- _ValidSchemaObject;
35
- string = Type.String();
36
- // uuid = Type.String({ format: 'uuid' });
37
- uuid = Type.String({
38
- 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}$',
39
- errorType: 'uuid'
40
- });
41
- uri = Type.String({
42
- pattern: '^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$',
43
- errorType: 'uri'
44
- });
45
- email = Type.String({
46
- 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])+)])',
47
- errorType: 'email'
48
- });
49
- number = Type.Transform(Type.Union([
50
- Type.Number(),
51
- Type.String({ pattern: '^[0-9]+$' }),
52
- Type.Boolean(),
53
- Type.Null(),
54
- Type.Date(),
55
- Type.BigInt()
56
- ], {
57
- errorType: 'number-like',
58
- openapiType: Type.Number()
59
- }))
60
- .Decode((value) => {
61
- if (typeof value !== 'number') {
62
- const num = Number(value);
63
- if (isNaN(num)) {
64
- throw new Error('Invalid number');
65
- }
66
- else {
67
- return num;
68
- }
69
- }
70
- return value;
71
- })
72
- .Encode(Number);
73
- bigint = Type.Transform(Type.Union([
74
- Type.BigInt(),
75
- Type.Number(),
76
- Type.String({ pattern: '^[0-9]+$' }),
77
- Type.Boolean(),
78
- Type.Date()
79
- ], {
80
- errorType: 'BigInt-like',
81
- openapiType: Type.BigInt()
82
- }))
83
- .Decode((value) => {
84
- if (typeof value !== 'bigint') {
85
- try {
86
- return BigInt(value instanceof Date ? value.getTime() : value);
87
- }
88
- catch {
89
- throw new Error('Invalid bigint');
90
- }
91
- }
92
- return value;
93
- })
94
- .Encode(BigInt);
95
- boolean = Type.Transform(Type.Union([
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
- errorType: 'boolean-like',
102
- openapiType: Type.Boolean()
103
- }))
104
- .Decode((value) => {
105
- if (typeof value === 'string') {
106
- if (value.toLowerCase() === 'true')
107
- return true;
108
- if (value.toLowerCase() === 'false')
109
- return false;
110
- }
111
- else {
112
- return value;
113
- }
114
- })
115
- .Encode(Boolean);
116
- date = Type.Transform(Type.Union([
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
- errorType: 'date',
126
- openapiType: Type.Date()
127
- }))
128
- .Decode((value) => {
129
- if (!(value instanceof Date)) {
130
- if (value === null || typeof value === 'boolean') {
131
- return new Date(value ? 1 : 0);
132
- }
133
- return new Date(value);
134
- }
135
- return value;
136
- })
137
- .Encode((value) => new Date(value));
138
- symbol = Type.Symbol();
139
- nullish = Type.Union([Type.Void(), Type.Null(), Type.Undefined()], {
140
- errorType: 'nullish'
141
- });
142
- any = Type.Any();
143
- unknown = Type.Unknown();
144
- never = Type.Never();
145
- /**
146
- * Extracts the error type of a schema for error messages.
147
- *
148
- * @param {TCatchall} schema - A schema that contains some type information.
149
- * @returns The type of the schema for error messages.
150
- */
151
- errorType(schema) {
152
- if (Object.hasOwn(schema, 'errorType')) {
153
- return schema.errorType;
154
- }
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)
168
- return;
169
- const errorMessages = errors.map((err, index) => {
170
- const path = err.path.length > 0 ? err.path.split('/').slice(1).join(' > ') : 'root';
171
- return `${index + 1}. Path: ${path}\n Message: ${err.message}`;
172
- });
173
- return `Validation failed with the following errors:\n${errorMessages.join('\n\n')}`;
174
- }
175
- /**
176
- * Compiles schema if this exists, for optimal performance.
177
- *
178
- * @param {TObject<TProperties>} schema - The schema to compile.
179
- * @returns {TypeCheck<T>} - The compiled schema.
180
- */
181
- compile(schema) {
182
- return TypeCompiler.Compile(schema);
183
- }
184
- /**
185
- * Convert a schema to a TypeBox schema.
186
- * @param {TIdiomaticSchema} schema - The schema to convert.
187
- * @returns {TResolve<T>} The resolved schema.
188
- */
189
- schemify(schema) {
190
- if (typeof schema === 'string' ||
191
- typeof schema === 'number' ||
192
- typeof schema === 'boolean') {
193
- return Type.Literal(schema);
194
- }
195
- if (KindGuard.IsSchema(schema) || schema instanceof TypeCheck) {
196
- return schema;
197
- }
198
- const newSchema = {};
199
- Object.getOwnPropertyNames(schema).forEach((key) => {
200
- if (KindGuard.IsSchema(schema[key])) {
201
- newSchema[key] = schema[key];
202
- }
203
- else {
204
- const schemified = this.schemify(schema[key]);
205
- newSchema[key] = schemified;
206
- }
207
- });
208
- return Type.Object(newSchema);
209
- }
210
- /**
211
- * Make a schema optional.
212
- * @param {TIdiomaticSchema} schema - The schema to make optional.
213
- * @returns {TOptional<TResolve<T>>} The optional schema.
214
- */
215
- optional(schema) {
216
- const schemified = KindGuard.IsSchema(schema)
217
- ? schema
218
- : this.schemify(schema);
219
- return Type.Optional(schemified);
220
- }
221
- /**
222
- * Create an array schema.
223
- * @param {TIdiomaticSchema} schema - The schema to use for array items.
224
- * @returns {TArray<TResolve<T>>} The array schema.
225
- */
226
- array(schema) {
227
- const schemified = KindGuard.IsSchema(schema)
228
- ? schema
229
- : this.schemify(schema);
230
- return Type.Array(schemified, {
231
- errorType: `array of ${this.errorType(schemified)}`
232
- });
233
- }
234
- /**
235
- * Create a union schema.
236
- * @param {TUnionContainer} schemas - The schemas to union.
237
- * @returns {TUnion<UnionTResolve<T>>} The union schema.
238
- *
239
- * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
240
- * This is a limitation of TypeBox. Consider using "optional" instead.
241
- */
242
- union(schemas) {
243
- const unionTypes = schemas.map((schema) => {
244
- return KindGuard.IsSchema(schema) ? schema : this.schemify(schema);
245
- });
246
- return Type.Union(unionTypes, {
247
- errorType: `any of ${unionTypes
248
- .map((s) => this.errorType(s))
249
- .join(', ')}`,
250
- errorSuffix: true
251
- });
252
- }
253
- /**
254
- * Create a literal schema.
255
- * @param {LiteralSchema} value - The literal value.
256
- * @returns {TLiteral<T>} The literal schema.
257
- */
258
- literal(value) {
259
- return Type.Literal(value, {
260
- errorType: value
261
- });
262
- }
263
- /**
264
- * Create an enum schema.
265
- * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
266
- * @returns {TUnion<UnionTResolve<T[]>>} The enum schema.
267
- */
268
- enum_(schemaEnum) {
269
- return this.union(Object.values(schemaEnum));
270
- }
271
- /**
272
- * Check if a value is a TypeBox object schema.
273
- * @param {unknown} value - The value to check.
274
- * @returns {boolean} True if the value is a TypeBox object schema.
275
- */
276
- isSchema(value) {
277
- return KindGuard.IsSchema(value);
278
- }
279
- /**
280
- * Validate a value against a schema.
281
- *
282
- * @param {TSchema} schema - The schema to validate against.
283
- * @param {unknown} value - The value to validate.
284
- * @returns {boolean} True if valid, otherwise false.
285
- */
286
- validate(schema, value) {
287
- if (schema instanceof TypeCheck) {
288
- return schema.Check(value);
289
- }
290
- else {
291
- const schemified = KindGuard.IsSchema(schema)
292
- ? schema
293
- : this.schemify(schema);
294
- return Value.Check(schemified, value);
295
- }
296
- }
297
- /**
298
- * Parse a value against a schema.
299
- *
300
- * @param {TSchema} schema - The schema to validate against.
301
- * @param {unknown} value - The value to validate.
302
- * @returns {ParseResult<TResolve<T>>} The parsing result.
303
- */
304
- parse(schema, value) {
305
- let errors = [];
306
- let conversion;
307
- if (schema instanceof TypeCheck) {
308
- if (schema.Check(value)) {
309
- conversion = schema.Decode(value);
310
- }
311
- else {
312
- errors = Array.from(schema.Errors(value));
313
- }
314
- }
315
- else {
316
- const schemified = KindGuard.IsSchema(schema)
317
- ? schema
318
- : this.schemify(schema);
319
- if (Value.Check(schemified, value)) {
320
- conversion = Value.Decode(schemified, value);
321
- }
322
- else {
323
- errors = Array.from(Value.Errors(schemified, value));
324
- }
325
- }
326
- return errors != null && errors.length === 0
327
- ? {
328
- ok: true,
329
- value: conversion
330
- }
331
- : {
332
- ok: false,
333
- error: this.prettyPrintTypeBoxErrors(errors)
334
- };
335
- }
336
- /**
337
- * Convert a schema to an OpenAPI schema object.
338
- * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
339
- * @returns {SchemaObject} The OpenAPI schema object.
340
- */
341
- openapi(schema) {
342
- const schemified = KindGuard.IsSchema(schema)
343
- ? schema
344
- : this.schemify(schema);
345
- if (Object.hasOwn(schemified, 'openapiType') ||
346
- KindGuard.IsLiteral(schemified)) {
347
- return schemified.openapiType;
348
- }
349
- const newSchema = Object.assign({}, schemified);
350
- if (Object.hasOwn(newSchema, 'properties')) {
351
- newSchema.properties = { ...schemified.properties };
352
- if (newSchema.properties) {
353
- Object.entries(newSchema.properties).forEach(([key, value]) => {
354
- if (KindGuard.IsSchema(value) && newSchema.properties) {
355
- newSchema.properties[key] = this.openapi(value);
356
- }
357
- });
358
- }
359
- }
360
- return newSchema;
361
- }
362
- }
@@ -1,59 +0,0 @@
1
- import { TObject as OriginalTObject, StaticDecode, TArray, TKind, TLiteral, TNever, TProperties, TSchema, TUnknown } from '@sinclair/typebox';
2
- import { TypeCheck } from '@sinclair/typebox/compiler';
3
- import { Increment, KeyTypes, LiteralSchema } from '../../shared/types/schema.types';
4
- /**
5
- * Represents a catch-all schema type.
6
- */
7
- export type TCatchall = TSchema;
8
- /**
9
- * Represents an outer array schema type. If the type T is an object shape, it will return an array schema of T. Otherwise, it returns TNever.
10
- *
11
- * @template T - The type to check and possibly convert to an array schema.
12
- */
13
- export type TOuterArray<T> = T extends TObject<TObjectShape> ? TArray<T> : TNever;
14
- /**
15
- * Represents the shape of an object schema.
16
- */
17
- export type TObjectShape = TProperties;
18
- /**
19
- * 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.
20
- *
21
- * @template T - The type to check and possibly convert to an object schema.
22
- */
23
- export type TObject<T> = T extends TObjectShape ? OriginalTObject<T> : TNever;
24
- /**
25
- * Translates a schema type T to its static type if T extends TCatchall. Otherwise, it returns TNever.
26
- *
27
- * @template T - The schema type to translate.
28
- */
29
- export type TSchemaTranslate<T> = T extends TCatchall ? StaticDecode<T> : TNever;
30
- /**
31
- * Represents an unboxed object schema where each key can have an idiomatic schema.
32
- */
33
- export type UnboxedTObjectSchema = {
34
- [key: KeyTypes]: TIdiomaticSchema;
35
- };
36
- /**
37
- * Represents an idiomatic schema which can be an unboxed object schema or a literal schema.
38
- */
39
- export type TIdiomaticSchema = UnboxedTObjectSchema | LiteralSchema;
40
- /**
41
- * Represents a container for a union of idiomatic schemas.
42
- */
43
- export type TUnionContainer = [...TIdiomaticSchema[]];
44
- /**
45
- * Resolves a union container to a tuple of resolved idiomatic schemas.
46
- *
47
- * @template T - The union container to resolve.
48
- */
49
- export type UnionTResolve<T extends TUnionContainer> = T extends (infer UnionTypes)[] ? [TResolve<UnionTypes>] : TNever;
50
- /**
51
- * Resolves a schema type T to its resolved type. The depth is limited to 12 to prevent infinite recursion, due to StaticDecode limitations.
52
- *
53
- * @template T - The schema type to resolve.
54
- * @template Depth - The current depth of the resolution.
55
- */
56
- export 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<{
57
- [K in keyof T]: TResolve<T[K], Increment<Depth>>;
58
- }> : T extends TypeCheck<infer Type> ? TResolve<Type, Increment<Depth>> : TNever;
59
- //# sourceMappingURL=schema.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.types.d.ts","sourceRoot":"","sources":["../../../../src/typebox/types/schema.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,YAAY,EACZ,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACd,MAAM,iCAAiC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC;AAEhC;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IACvB,CAAC,SAAS,OAAO,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,YAAY,CAAC,CAAC,CAAC,GACf,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,CAAC,GAAG,EAAE,QAAQ,GAAG,gBAAgB,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,aAAa,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,gBAAgB,EAAE,CAAC,CAAC;AAEtD;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,eAAe,IACjD,CAAC,SAAS,CAAC,MAAM,UAAU,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,KAAK,SAAS,MAAM,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,GAChE,QAAQ,GACR,CAAC,SAAS,aAAa,GACrB,QAAQ,CAAC,CAAC,CAAC,GACX,CAAC,SAAS,OAAO,GACf,CAAC,GACD,CAAC,SAAS,KAAK,GACb,CAAC,GACD,CAAC,SAAS,OAAO,CAAC,YAAY,CAAC,GAC7B,CAAC,GACD,CAAC,SAAS,oBAAoB,GAC5B,OAAO,CAAC;KACL,CAAC,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;CACjD,CAAC,GACF,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,GAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,GAChC,MAAM,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zod/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,99 +0,0 @@
1
- import { ZodSchemaValidator } from './zodSchemaValidator';
2
- /**
3
- * Factory function for creating a ZodSchemaValidator instance.
4
- * @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
5
- */
6
- export declare const SchemaValidator: () => ZodSchemaValidator;
7
- /**
8
- * Zod schema definition for string type.
9
- */
10
- export declare const string: import("zod").ZodString;
11
- /**
12
- * Zod schema definition for UUID type.
13
- */
14
- export declare const uuid: import("zod").ZodString;
15
- /**
16
- * Zod schema definition for email type.
17
- */
18
- export declare const email: import("zod").ZodString;
19
- /**
20
- * Zod schema definition for URI type.
21
- */
22
- export declare const uri: import("zod").ZodString;
23
- /**
24
- * Zod schema definition for number type.
25
- */
26
- export declare const number: import("zod").ZodNumber;
27
- /**
28
- * Zod schema definition for bigint type.
29
- */
30
- export declare const bigint: import("zod").ZodBigInt;
31
- /**
32
- * Zod schema definition for boolean type.
33
- */
34
- export declare const boolean: import("zod").ZodEffects<import("zod").ZodBoolean, boolean, unknown>;
35
- /**
36
- * Zod schema definition for date type.
37
- */
38
- export declare const date: import("zod").ZodDate;
39
- /**
40
- * Zod schema definition for symbol type.
41
- */
42
- export declare const symbol: import("zod").ZodSymbol;
43
- /**
44
- * Zod schema definition for undefined, null, void types.
45
- */
46
- export declare const nullish: import("zod").ZodUnion<[import("zod").ZodVoid, import("zod").ZodNull, import("zod").ZodUndefined]>;
47
- /**
48
- * Zod schema definition for any type.
49
- */
50
- export declare const any: import("zod").ZodAny;
51
- /**
52
- * Zod schema definition for unknown type.
53
- */
54
- export declare const unknown: import("zod").ZodUnknown;
55
- /**
56
- * Zod schema definition for never type.
57
- */
58
- export declare const never: import("zod").ZodNever;
59
- /**
60
- * Transforms valid schema into Zod schema.
61
- */
62
- export declare const schemify: <T extends import("./types/schema.types").ZodIdiomaticSchema>(schema: T) => import("./types/schema.types").ZodResolve<T>;
63
- /**
64
- * Makes a valid schema optional.
65
- */
66
- export declare const optional: <T extends import("./types/schema.types").ZodIdiomaticSchema>(schema: T) => import("zod").ZodOptional<import("./types/schema.types").ZodResolve<T>>;
67
- /**
68
- * Defines an array for a valid schema.
69
- */
70
- export declare const array: <T extends import("./types/schema.types").ZodIdiomaticSchema>(schema: T) => import("zod").ZodArray<import("./types/schema.types").ZodResolve<T>>;
71
- /**
72
- * Defines a union for a valid schema.
73
- */
74
- export declare const union: <T extends import("./types/schema.types").ZodUnionContainer>(schemas: T) => import("zod").ZodUnion<import("./types/schema.types").UnionZodResolve<T>>;
75
- /**
76
- * Defines a literal for a valid schema.
77
- */
78
- export declare const literal: <T extends import("../..").LiteralSchema>(value: T) => import("zod").ZodLiteral<import("./types/schema.types").ZodResolve<T>>;
79
- /**
80
- * Defines an enum for a valid schema.
81
- */
82
- export declare const enum_: <T extends import("../..").LiteralSchema>(schemaEnum: Record<string, T>) => import("zod").ZodUnion<import("./types/schema.types").UnionZodResolve<[T, T, ...T[]]>>;
83
- /**
84
- * Checks if a value is a Zod schema.
85
- */
86
- export declare const isSchema: (value: unknown) => value is import("zod").ZodSchema;
87
- /**
88
- * Validates a value against a valid schema.
89
- */
90
- export declare const validate: <T extends import("./types/schema.types").ZodCatchall>(schema: T, value: unknown) => boolean;
91
- /**
92
- * Parses a value to be conformant to a particular schema.
93
- */
94
- export declare const parse: <T extends import("./types/schema.types").ZodCatchall>(schema: T, value: unknown) => import("../..").ParseResult<import("./types/schema.types").ZodResolve<T>>;
95
- /**
96
- * Generates an OpenAPI schema object from a valid schema.
97
- */
98
- export declare const openapi: <T extends import("./types/schema.types").ZodIdiomaticSchema>(schema: T) => import("openapi3-ts/oas31").SchemaObject;
99
- //# sourceMappingURL=staticSchemaValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"staticSchemaValidator.d.ts","sourceRoot":"","sources":["../../../src/zod/staticSchemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,eAAe,0BAAiC,CAAC;AAI9D;;GAEG;AACH,eAAO,MAAM,MAAM,yBAA+B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,IAAI,yBAA6B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,KAAK,yBAA8B,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,GAAG,yBAA4B,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,MAAM,yBAA+B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,MAAM,yBAA+B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,OAAO,sEAAgC,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,IAAI,uBAA6B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,MAAM,yBAA+B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,OAAO,oGAAgC,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,GAAG,sBAA4B,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,OAAO,0BAAgC,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,KAAK,wBAA8B,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,QAAQ,0HAEpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,qJAEpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,kJAA0D,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,KAAK,uJAA0D,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,OAAO,+HAEnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,oKAA0D,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,QAAQ,sDAEpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,8FAEpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,gKAA0D,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,OAAO,sHAEnB,CAAC"}
@@ -1,99 +0,0 @@
1
- import { ZodSchemaValidator } from './zodSchemaValidator';
2
- /**
3
- * Factory function for creating a ZodSchemaValidator instance.
4
- * @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
5
- */
6
- export const SchemaValidator = () => new ZodSchemaValidator();
7
- const StaticSchemaValidator = SchemaValidator();
8
- /**
9
- * Zod schema definition for string type.
10
- */
11
- export const string = StaticSchemaValidator.string;
12
- /**
13
- * Zod schema definition for UUID type.
14
- */
15
- export const uuid = StaticSchemaValidator.uuid;
16
- /**
17
- * Zod schema definition for email type.
18
- */
19
- export const email = StaticSchemaValidator.email;
20
- /**
21
- * Zod schema definition for URI type.
22
- */
23
- export const uri = StaticSchemaValidator.uri;
24
- /**
25
- * Zod schema definition for number type.
26
- */
27
- export const number = StaticSchemaValidator.number;
28
- /**
29
- * Zod schema definition for bigint type.
30
- */
31
- export const bigint = StaticSchemaValidator.bigint;
32
- /**
33
- * Zod schema definition for boolean type.
34
- */
35
- export const boolean = StaticSchemaValidator.boolean;
36
- /**
37
- * Zod schema definition for date type.
38
- */
39
- export const date = StaticSchemaValidator.date;
40
- /**
41
- * Zod schema definition for symbol type.
42
- */
43
- export const symbol = StaticSchemaValidator.symbol;
44
- /**
45
- * Zod schema definition for undefined, null, void types.
46
- */
47
- export const nullish = StaticSchemaValidator.nullish;
48
- /**
49
- * Zod schema definition for any type.
50
- */
51
- export const any = StaticSchemaValidator.any;
52
- /**
53
- * Zod schema definition for unknown type.
54
- */
55
- export const unknown = StaticSchemaValidator.unknown;
56
- /**
57
- * Zod schema definition for never type.
58
- */
59
- export const never = StaticSchemaValidator.never;
60
- /**
61
- * Transforms valid schema into Zod schema.
62
- */
63
- export const schemify = StaticSchemaValidator.schemify.bind(StaticSchemaValidator);
64
- /**
65
- * Makes a valid schema optional.
66
- */
67
- export const optional = StaticSchemaValidator.optional.bind(StaticSchemaValidator);
68
- /**
69
- * Defines an array for a valid schema.
70
- */
71
- export const array = StaticSchemaValidator.array.bind(StaticSchemaValidator);
72
- /**
73
- * Defines a union for a valid schema.
74
- */
75
- export const union = StaticSchemaValidator.union.bind(StaticSchemaValidator);
76
- /**
77
- * Defines a literal for a valid schema.
78
- */
79
- export const literal = StaticSchemaValidator.literal.bind(StaticSchemaValidator);
80
- /**
81
- * Defines an enum for a valid schema.
82
- */
83
- export const enum_ = StaticSchemaValidator.enum_.bind(StaticSchemaValidator);
84
- /**
85
- * Checks if a value is a Zod schema.
86
- */
87
- export const isSchema = StaticSchemaValidator.isSchema.bind(StaticSchemaValidator);
88
- /**
89
- * Validates a value against a valid schema.
90
- */
91
- export const validate = StaticSchemaValidator.validate.bind(StaticSchemaValidator);
92
- /**
93
- * Parses a value to be conformant to a particular schema.
94
- */
95
- export const parse = StaticSchemaValidator.parse.bind(StaticSchemaValidator);
96
- /**
97
- * Generates an OpenAPI schema object from a valid schema.
98
- */
99
- export const openapi = StaticSchemaValidator.openapi.bind(StaticSchemaValidator);