zod 4.2.0-canary.20251202T062120 → 4.2.0-canary.20251213T203150
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.
- package/package.json +1 -1
- package/src/v4/classic/schemas.ts +97 -5
- package/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/src/v4/classic/tests/json.test.ts +4 -3
- package/src/v4/classic/tests/standard-schema.test.ts +77 -0
- package/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +66 -30
- package/src/v4/core/index.ts +2 -0
- package/src/v4/core/json-schema-generator.ts +124 -0
- package/src/v4/core/json-schema-processors.ts +630 -0
- package/src/v4/core/schemas.ts +8 -13
- package/src/v4/core/standard-schema.ts +114 -19
- package/src/v4/core/to-json-schema.ts +373 -827
- package/src/v4/mini/schemas.ts +2 -2
- package/src/v4/mini/tests/standard-schema.test.ts +17 -0
- package/v4/classic/schemas.cjs +48 -0
- package/v4/classic/schemas.d.cts +35 -0
- package/v4/classic/schemas.d.ts +35 -0
- package/v4/classic/schemas.js +48 -0
- package/v4/core/index.cjs +5 -1
- package/v4/core/index.d.cts +2 -0
- package/v4/core/index.d.ts +2 -0
- package/v4/core/index.js +2 -0
- package/v4/core/json-schema-generator.cjs +99 -0
- package/v4/core/json-schema-generator.d.cts +64 -0
- package/v4/core/json-schema-generator.d.ts +64 -0
- package/v4/core/json-schema-generator.js +95 -0
- package/v4/core/json-schema-processors.cjs +617 -0
- package/v4/core/json-schema-processors.d.cts +49 -0
- package/v4/core/json-schema-processors.d.ts +49 -0
- package/v4/core/json-schema-processors.js +574 -0
- package/v4/core/schemas.cjs +0 -10
- package/v4/core/schemas.d.cts +4 -1
- package/v4/core/schemas.d.ts +4 -1
- package/v4/core/schemas.js +0 -10
- package/v4/core/standard-schema.d.cts +90 -19
- package/v4/core/standard-schema.d.ts +90 -19
- package/v4/core/to-json-schema.cjs +302 -793
- package/v4/core/to-json-schema.d.cts +56 -33
- package/v4/core/to-json-schema.d.ts +56 -33
- package/v4/core/to-json-schema.js +296 -791
- package/v4/mini/schemas.d.cts +2 -2
- package/v4/mini/schemas.d.ts +2 -2
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import { util } from "../core/index.js";
|
|
3
|
+
import type { StandardSchemaWithJSONProps } from "../core/standard-schema.js";
|
|
3
4
|
import * as parse from "./parse.js";
|
|
5
|
+
export type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;
|
|
4
6
|
export interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
|
|
5
7
|
def: Internals["def"];
|
|
6
8
|
type: Internals["def"]["type"];
|
|
@@ -10,6 +12,9 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
|
|
|
10
12
|
_output: Internals["output"];
|
|
11
13
|
/** @deprecated Use `z.input<typeof schema>` instead. */
|
|
12
14
|
_input: Internals["input"];
|
|
15
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
16
|
+
/** Converts this schema to a JSON Schema representation. */
|
|
17
|
+
toJSONSchema(params?: core.ToJSONSchemaParams): core.ZodStandardJSONSchemaPayload<this>;
|
|
13
18
|
check(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
|
|
14
19
|
clone(def?: Internals["def"], params?: {
|
|
15
20
|
parent: boolean;
|
|
@@ -266,6 +271,7 @@ export declare const ZodJWT: core.$constructor<ZodJWT>;
|
|
|
266
271
|
export declare function jwt(params?: string | core.$ZodJWTParams): ZodJWT;
|
|
267
272
|
export interface ZodCustomStringFormat<Format extends string = string> extends ZodStringFormat<Format>, core.$ZodCustomStringFormat<Format> {
|
|
268
273
|
_zod: core.$ZodCustomStringFormatInternals<Format>;
|
|
274
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
269
275
|
}
|
|
270
276
|
export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
|
|
271
277
|
export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
|
|
@@ -411,6 +417,7 @@ export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodT
|
|
|
411
417
|
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
412
418
|
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
413
419
|
unwrap(): T;
|
|
420
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
414
421
|
}
|
|
415
422
|
export declare const ZodArray: core.$constructor<ZodArray>;
|
|
416
423
|
export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
|
|
@@ -421,6 +428,7 @@ export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLo
|
|
|
421
428
|
export interface ZodObject<
|
|
422
429
|
/** @ts-ignore Cast variance */
|
|
423
430
|
out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
|
|
431
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
424
432
|
shape: Shape;
|
|
425
433
|
keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
|
|
426
434
|
/** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
|
|
@@ -459,21 +467,25 @@ export declare function object<T extends core.$ZodLooseShape = Partial<Record<ne
|
|
|
459
467
|
export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, core.$strict>;
|
|
460
468
|
export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, core.$loose>;
|
|
461
469
|
export interface ZodUnion<T extends readonly core.SomeType[] = readonly core.$ZodType[]> extends _ZodType<core.$ZodUnionInternals<T>>, core.$ZodUnion<T> {
|
|
470
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
462
471
|
options: T;
|
|
463
472
|
}
|
|
464
473
|
export declare const ZodUnion: core.$constructor<ZodUnion>;
|
|
465
474
|
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
|
466
475
|
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[], Disc extends string = string> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options, Disc> {
|
|
476
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
467
477
|
_zod: core.$ZodDiscriminatedUnionInternals<Options, Disc>;
|
|
468
478
|
def: core.$ZodDiscriminatedUnionDef<Options, Disc>;
|
|
469
479
|
}
|
|
470
480
|
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
|
471
481
|
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types, Disc>;
|
|
472
482
|
export interface ZodIntersection<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodIntersectionInternals<A, B>>, core.$ZodIntersection<A, B> {
|
|
483
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
473
484
|
}
|
|
474
485
|
export declare const ZodIntersection: core.$constructor<ZodIntersection>;
|
|
475
486
|
export declare function intersection<T extends core.SomeType, U extends core.SomeType>(left: T, right: U): ZodIntersection<T, U>;
|
|
476
487
|
export interface ZodTuple<T extends util.TupleItems = readonly core.$ZodType[], Rest extends core.SomeType | null = core.$ZodType | null> extends _ZodType<core.$ZodTupleInternals<T, Rest>>, core.$ZodTuple<T, Rest> {
|
|
488
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
477
489
|
rest<Rest extends core.SomeType = core.$ZodType>(rest: Rest): ZodTuple<T, Rest>;
|
|
478
490
|
}
|
|
479
491
|
export declare const ZodTuple: core.$constructor<ZodTuple>;
|
|
@@ -481,6 +493,7 @@ export declare function tuple<T extends readonly [core.SomeType, ...core.SomeTyp
|
|
|
481
493
|
export declare function tuple<T extends readonly [core.SomeType, ...core.SomeType[]], Rest extends core.SomeType>(items: T, rest: Rest, params?: string | core.$ZodTupleParams): ZodTuple<T, Rest>;
|
|
482
494
|
export declare function tuple(items: [], params?: string | core.$ZodTupleParams): ZodTuple<[], null>;
|
|
483
495
|
export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodRecordInternals<Key, Value>>, core.$ZodRecord<Key, Value> {
|
|
496
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
484
497
|
keyType: Key;
|
|
485
498
|
valueType: Value;
|
|
486
499
|
}
|
|
@@ -488,12 +501,14 @@ export declare const ZodRecord: core.$constructor<ZodRecord>;
|
|
|
488
501
|
export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
|
|
489
502
|
export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key & core.$partial, Value>;
|
|
490
503
|
export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
|
|
504
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
491
505
|
keyType: Key;
|
|
492
506
|
valueType: Value;
|
|
493
507
|
}
|
|
494
508
|
export declare const ZodMap: core.$constructor<ZodMap>;
|
|
495
509
|
export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
|
|
496
510
|
export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
|
|
511
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
497
512
|
min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
|
|
498
513
|
nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
|
|
499
514
|
max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
|
|
@@ -504,6 +519,7 @@ export declare function set<Value extends core.SomeType>(valueType: Value, param
|
|
|
504
519
|
export interface ZodEnum<
|
|
505
520
|
/** @ts-ignore Cast variance */
|
|
506
521
|
out T extends util.EnumLike = util.EnumLike> extends _ZodType<core.$ZodEnumInternals<T>>, core.$ZodEnum<T> {
|
|
522
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
507
523
|
enum: T;
|
|
508
524
|
options: Array<T[keyof T]>;
|
|
509
525
|
extract<const U extends readonly (keyof T)[]>(values: U, params?: string | core.$ZodEnumParams): ZodEnum<util.Flatten<Pick<T, U[number]>>>;
|
|
@@ -522,6 +538,7 @@ export { _enum as enum };
|
|
|
522
538
|
*/
|
|
523
539
|
export declare function nativeEnum<T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T>;
|
|
524
540
|
export interface ZodLiteral<T extends util.Literal = util.Literal> extends _ZodType<core.$ZodLiteralInternals<T>>, core.$ZodLiteral<T> {
|
|
541
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
525
542
|
values: Set<T>;
|
|
526
543
|
/** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
|
|
527
544
|
value: T;
|
|
@@ -530,6 +547,7 @@ export declare const ZodLiteral: core.$constructor<ZodLiteral>;
|
|
|
530
547
|
export declare function literal<const T extends ReadonlyArray<util.Literal>>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T[number]>;
|
|
531
548
|
export declare function literal<const T extends util.Literal>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T>;
|
|
532
549
|
export interface ZodFile extends _ZodType<core.$ZodFileInternals>, core.$ZodFile {
|
|
550
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
533
551
|
min(size: number, params?: string | core.$ZodCheckMinSizeParams): this;
|
|
534
552
|
max(size: number, params?: string | core.$ZodCheckMaxSizeParams): this;
|
|
535
553
|
mime(types: util.MimeTypes | Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
|
|
@@ -537,21 +555,25 @@ export interface ZodFile extends _ZodType<core.$ZodFileInternals>, core.$ZodFile
|
|
|
537
555
|
export declare const ZodFile: core.$constructor<ZodFile>;
|
|
538
556
|
export declare function file(params?: string | core.$ZodFileParams): ZodFile;
|
|
539
557
|
export interface ZodTransform<O = unknown, I = unknown> extends _ZodType<core.$ZodTransformInternals<O, I>>, core.$ZodTransform<O, I> {
|
|
558
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
540
559
|
}
|
|
541
560
|
export declare const ZodTransform: core.$constructor<ZodTransform>;
|
|
542
561
|
export declare function transform<I = unknown, O = I>(fn: (input: I, ctx: core.ParsePayload) => O): ZodTransform<Awaited<O>, I>;
|
|
543
562
|
export interface ZodOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodOptionalInternals<T>>, core.$ZodOptional<T> {
|
|
563
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
544
564
|
unwrap(): T;
|
|
545
565
|
}
|
|
546
566
|
export declare const ZodOptional: core.$constructor<ZodOptional>;
|
|
547
567
|
export declare function optional<T extends core.SomeType>(innerType: T): ZodOptional<T>;
|
|
548
568
|
export interface ZodNullable<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodNullableInternals<T>>, core.$ZodNullable<T> {
|
|
569
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
549
570
|
unwrap(): T;
|
|
550
571
|
}
|
|
551
572
|
export declare const ZodNullable: core.$constructor<ZodNullable>;
|
|
552
573
|
export declare function nullable<T extends core.SomeType>(innerType: T): ZodNullable<T>;
|
|
553
574
|
export declare function nullish<T extends core.SomeType>(innerType: T): ZodOptional<ZodNullable<T>>;
|
|
554
575
|
export interface ZodDefault<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodDefaultInternals<T>>, core.$ZodDefault<T> {
|
|
576
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
555
577
|
unwrap(): T;
|
|
556
578
|
/** @deprecated Use `.unwrap()` instead. */
|
|
557
579
|
removeDefault(): T;
|
|
@@ -559,21 +581,25 @@ export interface ZodDefault<T extends core.SomeType = core.$ZodType> extends _Zo
|
|
|
559
581
|
export declare const ZodDefault: core.$constructor<ZodDefault>;
|
|
560
582
|
export declare function _default<T extends core.SomeType>(innerType: T, defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)): ZodDefault<T>;
|
|
561
583
|
export interface ZodPrefault<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPrefaultInternals<T>>, core.$ZodPrefault<T> {
|
|
584
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
562
585
|
unwrap(): T;
|
|
563
586
|
}
|
|
564
587
|
export declare const ZodPrefault: core.$constructor<ZodPrefault>;
|
|
565
588
|
export declare function prefault<T extends core.SomeType>(innerType: T, defaultValue: core.input<T> | (() => core.input<T>)): ZodPrefault<T>;
|
|
566
589
|
export interface ZodNonOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodNonOptionalInternals<T>>, core.$ZodNonOptional<T> {
|
|
590
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
567
591
|
unwrap(): T;
|
|
568
592
|
}
|
|
569
593
|
export declare const ZodNonOptional: core.$constructor<ZodNonOptional>;
|
|
570
594
|
export declare function nonoptional<T extends core.SomeType>(innerType: T, params?: string | core.$ZodNonOptionalParams): ZodNonOptional<T>;
|
|
571
595
|
export interface ZodSuccess<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSuccessInternals<T>>, core.$ZodSuccess<T> {
|
|
596
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
572
597
|
unwrap(): T;
|
|
573
598
|
}
|
|
574
599
|
export declare const ZodSuccess: core.$constructor<ZodSuccess>;
|
|
575
600
|
export declare function success<T extends core.SomeType>(innerType: T): ZodSuccess<T>;
|
|
576
601
|
export interface ZodCatch<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodCatchInternals<T>>, core.$ZodCatch<T> {
|
|
602
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
577
603
|
unwrap(): T;
|
|
578
604
|
/** @deprecated Use `.unwrap()` instead. */
|
|
579
605
|
removeCatch(): T;
|
|
@@ -582,16 +608,19 @@ export declare const ZodCatch: core.$constructor<ZodCatch>;
|
|
|
582
608
|
declare function _catch<T extends core.SomeType>(innerType: T, catchValue: core.output<T> | ((ctx: core.$ZodCatchCtx) => core.output<T>)): ZodCatch<T>;
|
|
583
609
|
export { _catch as catch };
|
|
584
610
|
export interface ZodNaN extends _ZodType<core.$ZodNaNInternals>, core.$ZodNaN {
|
|
611
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
585
612
|
}
|
|
586
613
|
export declare const ZodNaN: core.$constructor<ZodNaN>;
|
|
587
614
|
export declare function nan(params?: string | core.$ZodNaNParams): ZodNaN;
|
|
588
615
|
export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPipeInternals<A, B>>, core.$ZodPipe<A, B> {
|
|
616
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
589
617
|
in: A;
|
|
590
618
|
out: B;
|
|
591
619
|
}
|
|
592
620
|
export declare const ZodPipe: core.$constructor<ZodPipe>;
|
|
593
621
|
export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
|
|
594
622
|
export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends ZodPipe<A, B>, core.$ZodCodec<A, B> {
|
|
623
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
595
624
|
_zod: core.$ZodCodecInternals<A, B>;
|
|
596
625
|
def: core.$ZodCodecDef<A, B>;
|
|
597
626
|
}
|
|
@@ -601,25 +630,30 @@ export declare function codec<const A extends core.SomeType, B extends core.Some
|
|
|
601
630
|
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
|
602
631
|
}): ZodCodec<A, B>;
|
|
603
632
|
export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
|
|
633
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
604
634
|
unwrap(): T;
|
|
605
635
|
}
|
|
606
636
|
export declare const ZodReadonly: core.$constructor<ZodReadonly>;
|
|
607
637
|
export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
|
|
608
638
|
export interface ZodTemplateLiteral<Template extends string = string> extends _ZodType<core.$ZodTemplateLiteralInternals<Template>>, core.$ZodTemplateLiteral<Template> {
|
|
639
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
609
640
|
}
|
|
610
641
|
export declare const ZodTemplateLiteral: core.$constructor<ZodTemplateLiteral>;
|
|
611
642
|
export declare function templateLiteral<const Parts extends core.$ZodTemplateLiteralPart[]>(parts: Parts, params?: string | core.$ZodTemplateLiteralParams): ZodTemplateLiteral<core.$PartsToTemplateLiteral<Parts>>;
|
|
612
643
|
export interface ZodLazy<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodLazyInternals<T>>, core.$ZodLazy<T> {
|
|
644
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
613
645
|
unwrap(): T;
|
|
614
646
|
}
|
|
615
647
|
export declare const ZodLazy: core.$constructor<ZodLazy>;
|
|
616
648
|
export declare function lazy<T extends core.SomeType>(getter: () => T): ZodLazy<T>;
|
|
617
649
|
export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPromiseInternals<T>>, core.$ZodPromise<T> {
|
|
650
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
618
651
|
unwrap(): T;
|
|
619
652
|
}
|
|
620
653
|
export declare const ZodPromise: core.$constructor<ZodPromise>;
|
|
621
654
|
export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
|
|
622
655
|
export interface ZodFunction<Args extends core.$ZodFunctionIn = core.$ZodFunctionIn, Returns extends core.$ZodFunctionOut = core.$ZodFunctionOut> extends _ZodType<core.$ZodFunctionInternals<Args, Returns>>, core.$ZodFunction<Args, Returns> {
|
|
656
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
623
657
|
_def: core.$ZodFunctionDef<Args, Returns>;
|
|
624
658
|
_input: core.$InferInnerFunctionType<Args, Returns>;
|
|
625
659
|
_output: core.$InferOuterFunctionType<Args, Returns>;
|
|
@@ -649,6 +683,7 @@ export declare function _function<In extends core.$ZodFunctionIn = core.$ZodFunc
|
|
|
649
683
|
}): ZodFunction<In, Out>;
|
|
650
684
|
export { _function as function };
|
|
651
685
|
export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
|
|
686
|
+
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
652
687
|
}
|
|
653
688
|
export declare const ZodCustom: core.$constructor<ZodCustom>;
|
|
654
689
|
export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
|
package/v4/classic/schemas.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import { util } from "../core/index.js";
|
|
3
|
+
import * as processors from "../core/json-schema-processors.js";
|
|
4
|
+
import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
|
|
3
5
|
import * as checks from "./checks.js";
|
|
4
6
|
import * as iso from "./iso.js";
|
|
5
7
|
import * as parse from "./parse.js";
|
|
6
8
|
export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
|
|
7
9
|
core.$ZodType.init(inst, def);
|
|
10
|
+
Object.assign(inst["~standard"], {
|
|
11
|
+
jsonSchema: {
|
|
12
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
13
|
+
output: createStandardJSONSchemaMethod(inst, "output"),
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
8
17
|
inst.def = def;
|
|
9
18
|
inst.type = def.type;
|
|
10
19
|
Object.defineProperty(inst, "_def", { value: def });
|
|
@@ -86,6 +95,7 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
86
95
|
export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, def) => {
|
|
87
96
|
core.$ZodString.init(inst, def);
|
|
88
97
|
ZodType.init(inst, def);
|
|
98
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.stringProcessor(inst, ctx, json, params);
|
|
89
99
|
const bag = inst._zod.bag;
|
|
90
100
|
inst.format = bag.format ?? null;
|
|
91
101
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -348,6 +358,7 @@ export function hash(alg, params) {
|
|
|
348
358
|
export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
|
|
349
359
|
core.$ZodNumber.init(inst, def);
|
|
350
360
|
ZodType.init(inst, def);
|
|
361
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
|
|
351
362
|
inst.gt = (value, params) => inst.check(checks.gt(value, params));
|
|
352
363
|
inst.gte = (value, params) => inst.check(checks.gte(value, params));
|
|
353
364
|
inst.min = (value, params) => inst.check(checks.gte(value, params));
|
|
@@ -398,6 +409,7 @@ export function uint32(params) {
|
|
|
398
409
|
export const ZodBoolean = /*@__PURE__*/ core.$constructor("ZodBoolean", (inst, def) => {
|
|
399
410
|
core.$ZodBoolean.init(inst, def);
|
|
400
411
|
ZodType.init(inst, def);
|
|
412
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.booleanProcessor(inst, ctx, json, params);
|
|
401
413
|
});
|
|
402
414
|
export function boolean(params) {
|
|
403
415
|
return core._boolean(ZodBoolean, params);
|
|
@@ -405,6 +417,7 @@ export function boolean(params) {
|
|
|
405
417
|
export const ZodBigInt = /*@__PURE__*/ core.$constructor("ZodBigInt", (inst, def) => {
|
|
406
418
|
core.$ZodBigInt.init(inst, def);
|
|
407
419
|
ZodType.init(inst, def);
|
|
420
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
|
|
408
421
|
inst.gte = (value, params) => inst.check(checks.gte(value, params));
|
|
409
422
|
inst.min = (value, params) => inst.check(checks.gte(value, params));
|
|
410
423
|
inst.gt = (value, params) => inst.check(checks.gt(value, params));
|
|
@@ -441,6 +454,7 @@ export function uint64(params) {
|
|
|
441
454
|
export const ZodSymbol = /*@__PURE__*/ core.$constructor("ZodSymbol", (inst, def) => {
|
|
442
455
|
core.$ZodSymbol.init(inst, def);
|
|
443
456
|
ZodType.init(inst, def);
|
|
457
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.symbolProcessor(inst, ctx, json, params);
|
|
444
458
|
});
|
|
445
459
|
export function symbol(params) {
|
|
446
460
|
return core._symbol(ZodSymbol, params);
|
|
@@ -448,6 +462,7 @@ export function symbol(params) {
|
|
|
448
462
|
export const ZodUndefined = /*@__PURE__*/ core.$constructor("ZodUndefined", (inst, def) => {
|
|
449
463
|
core.$ZodUndefined.init(inst, def);
|
|
450
464
|
ZodType.init(inst, def);
|
|
465
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.undefinedProcessor(inst, ctx, json, params);
|
|
451
466
|
});
|
|
452
467
|
function _undefined(params) {
|
|
453
468
|
return core._undefined(ZodUndefined, params);
|
|
@@ -456,6 +471,7 @@ export { _undefined as undefined };
|
|
|
456
471
|
export const ZodNull = /*@__PURE__*/ core.$constructor("ZodNull", (inst, def) => {
|
|
457
472
|
core.$ZodNull.init(inst, def);
|
|
458
473
|
ZodType.init(inst, def);
|
|
474
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nullProcessor(inst, ctx, json, params);
|
|
459
475
|
});
|
|
460
476
|
function _null(params) {
|
|
461
477
|
return core._null(ZodNull, params);
|
|
@@ -464,6 +480,7 @@ export { _null as null };
|
|
|
464
480
|
export const ZodAny = /*@__PURE__*/ core.$constructor("ZodAny", (inst, def) => {
|
|
465
481
|
core.$ZodAny.init(inst, def);
|
|
466
482
|
ZodType.init(inst, def);
|
|
483
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.anyProcessor(inst, ctx, json, params);
|
|
467
484
|
});
|
|
468
485
|
export function any() {
|
|
469
486
|
return core._any(ZodAny);
|
|
@@ -471,6 +488,7 @@ export function any() {
|
|
|
471
488
|
export const ZodUnknown = /*@__PURE__*/ core.$constructor("ZodUnknown", (inst, def) => {
|
|
472
489
|
core.$ZodUnknown.init(inst, def);
|
|
473
490
|
ZodType.init(inst, def);
|
|
491
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.unknownProcessor(inst, ctx, json, params);
|
|
474
492
|
});
|
|
475
493
|
export function unknown() {
|
|
476
494
|
return core._unknown(ZodUnknown);
|
|
@@ -478,6 +496,7 @@ export function unknown() {
|
|
|
478
496
|
export const ZodNever = /*@__PURE__*/ core.$constructor("ZodNever", (inst, def) => {
|
|
479
497
|
core.$ZodNever.init(inst, def);
|
|
480
498
|
ZodType.init(inst, def);
|
|
499
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.neverProcessor(inst, ctx, json, params);
|
|
481
500
|
});
|
|
482
501
|
export function never(params) {
|
|
483
502
|
return core._never(ZodNever, params);
|
|
@@ -485,6 +504,7 @@ export function never(params) {
|
|
|
485
504
|
export const ZodVoid = /*@__PURE__*/ core.$constructor("ZodVoid", (inst, def) => {
|
|
486
505
|
core.$ZodVoid.init(inst, def);
|
|
487
506
|
ZodType.init(inst, def);
|
|
507
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.voidProcessor(inst, ctx, json, params);
|
|
488
508
|
});
|
|
489
509
|
function _void(params) {
|
|
490
510
|
return core._void(ZodVoid, params);
|
|
@@ -493,6 +513,7 @@ export { _void as void };
|
|
|
493
513
|
export const ZodDate = /*@__PURE__*/ core.$constructor("ZodDate", (inst, def) => {
|
|
494
514
|
core.$ZodDate.init(inst, def);
|
|
495
515
|
ZodType.init(inst, def);
|
|
516
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
|
|
496
517
|
inst.min = (value, params) => inst.check(checks.gte(value, params));
|
|
497
518
|
inst.max = (value, params) => inst.check(checks.lte(value, params));
|
|
498
519
|
const c = inst._zod.bag;
|
|
@@ -505,6 +526,7 @@ export function date(params) {
|
|
|
505
526
|
export const ZodArray = /*@__PURE__*/ core.$constructor("ZodArray", (inst, def) => {
|
|
506
527
|
core.$ZodArray.init(inst, def);
|
|
507
528
|
ZodType.init(inst, def);
|
|
529
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.arrayProcessor(inst, ctx, json, params);
|
|
508
530
|
inst.element = def.element;
|
|
509
531
|
inst.min = (minLength, params) => inst.check(checks.minLength(minLength, params));
|
|
510
532
|
inst.nonempty = (params) => inst.check(checks.minLength(1, params));
|
|
@@ -523,6 +545,7 @@ export function keyof(schema) {
|
|
|
523
545
|
export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def) => {
|
|
524
546
|
core.$ZodObjectJIT.init(inst, def);
|
|
525
547
|
ZodType.init(inst, def);
|
|
548
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.objectProcessor(inst, ctx, json, params);
|
|
526
549
|
util.defineLazy(inst, "shape", () => {
|
|
527
550
|
return def.shape;
|
|
528
551
|
});
|
|
@@ -573,6 +596,7 @@ export function looseObject(shape, params) {
|
|
|
573
596
|
export const ZodUnion = /*@__PURE__*/ core.$constructor("ZodUnion", (inst, def) => {
|
|
574
597
|
core.$ZodUnion.init(inst, def);
|
|
575
598
|
ZodType.init(inst, def);
|
|
599
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);
|
|
576
600
|
inst.options = def.options;
|
|
577
601
|
});
|
|
578
602
|
export function union(options, params) {
|
|
@@ -598,6 +622,7 @@ export function discriminatedUnion(discriminator, options, params) {
|
|
|
598
622
|
export const ZodIntersection = /*@__PURE__*/ core.$constructor("ZodIntersection", (inst, def) => {
|
|
599
623
|
core.$ZodIntersection.init(inst, def);
|
|
600
624
|
ZodType.init(inst, def);
|
|
625
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.intersectionProcessor(inst, ctx, json, params);
|
|
601
626
|
});
|
|
602
627
|
export function intersection(left, right) {
|
|
603
628
|
return new ZodIntersection({
|
|
@@ -609,6 +634,7 @@ export function intersection(left, right) {
|
|
|
609
634
|
export const ZodTuple = /*@__PURE__*/ core.$constructor("ZodTuple", (inst, def) => {
|
|
610
635
|
core.$ZodTuple.init(inst, def);
|
|
611
636
|
ZodType.init(inst, def);
|
|
637
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.tupleProcessor(inst, ctx, json, params);
|
|
612
638
|
inst.rest = (rest) => inst.clone({
|
|
613
639
|
...inst._zod.def,
|
|
614
640
|
rest: rest,
|
|
@@ -628,6 +654,7 @@ export function tuple(items, _paramsOrRest, _params) {
|
|
|
628
654
|
export const ZodRecord = /*@__PURE__*/ core.$constructor("ZodRecord", (inst, def) => {
|
|
629
655
|
core.$ZodRecord.init(inst, def);
|
|
630
656
|
ZodType.init(inst, def);
|
|
657
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.recordProcessor(inst, ctx, json, params);
|
|
631
658
|
inst.keyType = def.keyType;
|
|
632
659
|
inst.valueType = def.valueType;
|
|
633
660
|
});
|
|
@@ -653,6 +680,7 @@ export function partialRecord(keyType, valueType, params) {
|
|
|
653
680
|
export const ZodMap = /*@__PURE__*/ core.$constructor("ZodMap", (inst, def) => {
|
|
654
681
|
core.$ZodMap.init(inst, def);
|
|
655
682
|
ZodType.init(inst, def);
|
|
683
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.mapProcessor(inst, ctx, json, params);
|
|
656
684
|
inst.keyType = def.keyType;
|
|
657
685
|
inst.valueType = def.valueType;
|
|
658
686
|
});
|
|
@@ -667,6 +695,7 @@ export function map(keyType, valueType, params) {
|
|
|
667
695
|
export const ZodSet = /*@__PURE__*/ core.$constructor("ZodSet", (inst, def) => {
|
|
668
696
|
core.$ZodSet.init(inst, def);
|
|
669
697
|
ZodType.init(inst, def);
|
|
698
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.setProcessor(inst, ctx, json, params);
|
|
670
699
|
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
671
700
|
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
672
701
|
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
@@ -682,6 +711,7 @@ export function set(valueType, params) {
|
|
|
682
711
|
export const ZodEnum = /*@__PURE__*/ core.$constructor("ZodEnum", (inst, def) => {
|
|
683
712
|
core.$ZodEnum.init(inst, def);
|
|
684
713
|
ZodType.init(inst, def);
|
|
714
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.enumProcessor(inst, ctx, json, params);
|
|
685
715
|
inst.enum = def.entries;
|
|
686
716
|
inst.options = Object.values(def.entries);
|
|
687
717
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -744,6 +774,7 @@ export function nativeEnum(entries, params) {
|
|
|
744
774
|
export const ZodLiteral = /*@__PURE__*/ core.$constructor("ZodLiteral", (inst, def) => {
|
|
745
775
|
core.$ZodLiteral.init(inst, def);
|
|
746
776
|
ZodType.init(inst, def);
|
|
777
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.literalProcessor(inst, ctx, json, params);
|
|
747
778
|
inst.values = new Set(def.values);
|
|
748
779
|
Object.defineProperty(inst, "value", {
|
|
749
780
|
get() {
|
|
@@ -764,6 +795,7 @@ export function literal(value, params) {
|
|
|
764
795
|
export const ZodFile = /*@__PURE__*/ core.$constructor("ZodFile", (inst, def) => {
|
|
765
796
|
core.$ZodFile.init(inst, def);
|
|
766
797
|
ZodType.init(inst, def);
|
|
798
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.fileProcessor(inst, ctx, json, params);
|
|
767
799
|
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
768
800
|
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
769
801
|
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -774,6 +806,7 @@ export function file(params) {
|
|
|
774
806
|
export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (inst, def) => {
|
|
775
807
|
core.$ZodTransform.init(inst, def);
|
|
776
808
|
ZodType.init(inst, def);
|
|
809
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.transformProcessor(inst, ctx, json, params);
|
|
777
810
|
inst._zod.parse = (payload, _ctx) => {
|
|
778
811
|
if (_ctx.direction === "backward") {
|
|
779
812
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -814,6 +847,7 @@ export function transform(fn) {
|
|
|
814
847
|
export const ZodOptional = /*@__PURE__*/ core.$constructor("ZodOptional", (inst, def) => {
|
|
815
848
|
core.$ZodOptional.init(inst, def);
|
|
816
849
|
ZodType.init(inst, def);
|
|
850
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);
|
|
817
851
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
818
852
|
});
|
|
819
853
|
export function optional(innerType) {
|
|
@@ -825,6 +859,7 @@ export function optional(innerType) {
|
|
|
825
859
|
export const ZodNullable = /*@__PURE__*/ core.$constructor("ZodNullable", (inst, def) => {
|
|
826
860
|
core.$ZodNullable.init(inst, def);
|
|
827
861
|
ZodType.init(inst, def);
|
|
862
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nullableProcessor(inst, ctx, json, params);
|
|
828
863
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
829
864
|
});
|
|
830
865
|
export function nullable(innerType) {
|
|
@@ -840,6 +875,7 @@ export function nullish(innerType) {
|
|
|
840
875
|
export const ZodDefault = /*@__PURE__*/ core.$constructor("ZodDefault", (inst, def) => {
|
|
841
876
|
core.$ZodDefault.init(inst, def);
|
|
842
877
|
ZodType.init(inst, def);
|
|
878
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.defaultProcessor(inst, ctx, json, params);
|
|
843
879
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
844
880
|
inst.removeDefault = inst.unwrap;
|
|
845
881
|
});
|
|
@@ -855,6 +891,7 @@ export function _default(innerType, defaultValue) {
|
|
|
855
891
|
export const ZodPrefault = /*@__PURE__*/ core.$constructor("ZodPrefault", (inst, def) => {
|
|
856
892
|
core.$ZodPrefault.init(inst, def);
|
|
857
893
|
ZodType.init(inst, def);
|
|
894
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.prefaultProcessor(inst, ctx, json, params);
|
|
858
895
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
859
896
|
});
|
|
860
897
|
export function prefault(innerType, defaultValue) {
|
|
@@ -869,6 +906,7 @@ export function prefault(innerType, defaultValue) {
|
|
|
869
906
|
export const ZodNonOptional = /*@__PURE__*/ core.$constructor("ZodNonOptional", (inst, def) => {
|
|
870
907
|
core.$ZodNonOptional.init(inst, def);
|
|
871
908
|
ZodType.init(inst, def);
|
|
909
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nonoptionalProcessor(inst, ctx, json, params);
|
|
872
910
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
873
911
|
});
|
|
874
912
|
export function nonoptional(innerType, params) {
|
|
@@ -881,6 +919,7 @@ export function nonoptional(innerType, params) {
|
|
|
881
919
|
export const ZodSuccess = /*@__PURE__*/ core.$constructor("ZodSuccess", (inst, def) => {
|
|
882
920
|
core.$ZodSuccess.init(inst, def);
|
|
883
921
|
ZodType.init(inst, def);
|
|
922
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.successProcessor(inst, ctx, json, params);
|
|
884
923
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
885
924
|
});
|
|
886
925
|
export function success(innerType) {
|
|
@@ -892,6 +931,7 @@ export function success(innerType) {
|
|
|
892
931
|
export const ZodCatch = /*@__PURE__*/ core.$constructor("ZodCatch", (inst, def) => {
|
|
893
932
|
core.$ZodCatch.init(inst, def);
|
|
894
933
|
ZodType.init(inst, def);
|
|
934
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.catchProcessor(inst, ctx, json, params);
|
|
895
935
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
896
936
|
inst.removeCatch = inst.unwrap;
|
|
897
937
|
});
|
|
@@ -906,6 +946,7 @@ export { _catch as catch };
|
|
|
906
946
|
export const ZodNaN = /*@__PURE__*/ core.$constructor("ZodNaN", (inst, def) => {
|
|
907
947
|
core.$ZodNaN.init(inst, def);
|
|
908
948
|
ZodType.init(inst, def);
|
|
949
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nanProcessor(inst, ctx, json, params);
|
|
909
950
|
});
|
|
910
951
|
export function nan(params) {
|
|
911
952
|
return core._nan(ZodNaN, params);
|
|
@@ -913,6 +954,7 @@ export function nan(params) {
|
|
|
913
954
|
export const ZodPipe = /*@__PURE__*/ core.$constructor("ZodPipe", (inst, def) => {
|
|
914
955
|
core.$ZodPipe.init(inst, def);
|
|
915
956
|
ZodType.init(inst, def);
|
|
957
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.pipeProcessor(inst, ctx, json, params);
|
|
916
958
|
inst.in = def.in;
|
|
917
959
|
inst.out = def.out;
|
|
918
960
|
});
|
|
@@ -940,6 +982,7 @@ export function codec(in_, out, params) {
|
|
|
940
982
|
export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst, def) => {
|
|
941
983
|
core.$ZodReadonly.init(inst, def);
|
|
942
984
|
ZodType.init(inst, def);
|
|
985
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.readonlyProcessor(inst, ctx, json, params);
|
|
943
986
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
944
987
|
});
|
|
945
988
|
export function readonly(innerType) {
|
|
@@ -951,6 +994,7 @@ export function readonly(innerType) {
|
|
|
951
994
|
export const ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("ZodTemplateLiteral", (inst, def) => {
|
|
952
995
|
core.$ZodTemplateLiteral.init(inst, def);
|
|
953
996
|
ZodType.init(inst, def);
|
|
997
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.templateLiteralProcessor(inst, ctx, json, params);
|
|
954
998
|
});
|
|
955
999
|
export function templateLiteral(parts, params) {
|
|
956
1000
|
return new ZodTemplateLiteral({
|
|
@@ -962,6 +1006,7 @@ export function templateLiteral(parts, params) {
|
|
|
962
1006
|
export const ZodLazy = /*@__PURE__*/ core.$constructor("ZodLazy", (inst, def) => {
|
|
963
1007
|
core.$ZodLazy.init(inst, def);
|
|
964
1008
|
ZodType.init(inst, def);
|
|
1009
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.lazyProcessor(inst, ctx, json, params);
|
|
965
1010
|
inst.unwrap = () => inst._zod.def.getter();
|
|
966
1011
|
});
|
|
967
1012
|
export function lazy(getter) {
|
|
@@ -973,6 +1018,7 @@ export function lazy(getter) {
|
|
|
973
1018
|
export const ZodPromise = /*@__PURE__*/ core.$constructor("ZodPromise", (inst, def) => {
|
|
974
1019
|
core.$ZodPromise.init(inst, def);
|
|
975
1020
|
ZodType.init(inst, def);
|
|
1021
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.promiseProcessor(inst, ctx, json, params);
|
|
976
1022
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
977
1023
|
});
|
|
978
1024
|
export function promise(innerType) {
|
|
@@ -984,6 +1030,7 @@ export function promise(innerType) {
|
|
|
984
1030
|
export const ZodFunction = /*@__PURE__*/ core.$constructor("ZodFunction", (inst, def) => {
|
|
985
1031
|
core.$ZodFunction.init(inst, def);
|
|
986
1032
|
ZodType.init(inst, def);
|
|
1033
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.functionProcessor(inst, ctx, json, params);
|
|
987
1034
|
});
|
|
988
1035
|
export function _function(params) {
|
|
989
1036
|
return new ZodFunction({
|
|
@@ -996,6 +1043,7 @@ export { _function as function };
|
|
|
996
1043
|
export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
|
|
997
1044
|
core.$ZodCustom.init(inst, def);
|
|
998
1045
|
ZodType.init(inst, def);
|
|
1046
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
|
|
999
1047
|
});
|
|
1000
1048
|
// custom checks
|
|
1001
1049
|
export function check(fn) {
|
package/v4/core/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.JSONSchema = exports.locales = exports.regexes = exports.util = void 0;
|
|
29
|
+
exports.JSONSchema = exports.JSONSchemaGenerator = exports.toJSONSchema = exports.locales = exports.regexes = exports.util = void 0;
|
|
30
30
|
__exportStar(require("./core.cjs"), exports);
|
|
31
31
|
__exportStar(require("./parse.cjs"), exports);
|
|
32
32
|
__exportStar(require("./errors.cjs"), exports);
|
|
@@ -40,4 +40,8 @@ __exportStar(require("./registries.cjs"), exports);
|
|
|
40
40
|
__exportStar(require("./doc.cjs"), exports);
|
|
41
41
|
__exportStar(require("./api.cjs"), exports);
|
|
42
42
|
__exportStar(require("./to-json-schema.cjs"), exports);
|
|
43
|
+
var json_schema_processors_js_1 = require("./json-schema-processors.cjs");
|
|
44
|
+
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return json_schema_processors_js_1.toJSONSchema; } });
|
|
45
|
+
var json_schema_generator_js_1 = require("./json-schema-generator.cjs");
|
|
46
|
+
Object.defineProperty(exports, "JSONSchemaGenerator", { enumerable: true, get: function () { return json_schema_generator_js_1.JSONSchemaGenerator; } });
|
|
43
47
|
exports.JSONSchema = __importStar(require("./json-schema.cjs"));
|
package/v4/core/index.d.cts
CHANGED
|
@@ -11,4 +11,6 @@ export * from "./registries.cjs";
|
|
|
11
11
|
export * from "./doc.cjs";
|
|
12
12
|
export * from "./api.cjs";
|
|
13
13
|
export * from "./to-json-schema.cjs";
|
|
14
|
+
export { toJSONSchema } from "./json-schema-processors.cjs";
|
|
15
|
+
export { JSONSchemaGenerator } from "./json-schema-generator.cjs";
|
|
14
16
|
export * as JSONSchema from "./json-schema.cjs";
|
package/v4/core/index.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ export * from "./registries.js";
|
|
|
11
11
|
export * from "./doc.js";
|
|
12
12
|
export * from "./api.js";
|
|
13
13
|
export * from "./to-json-schema.js";
|
|
14
|
+
export { toJSONSchema } from "./json-schema-processors.js";
|
|
15
|
+
export { JSONSchemaGenerator } from "./json-schema-generator.js";
|
|
14
16
|
export * as JSONSchema from "./json-schema.js";
|
package/v4/core/index.js
CHANGED
|
@@ -11,4 +11,6 @@ export * from "./registries.js";
|
|
|
11
11
|
export * from "./doc.js";
|
|
12
12
|
export * from "./api.js";
|
|
13
13
|
export * from "./to-json-schema.js";
|
|
14
|
+
export { toJSONSchema } from "./json-schema-processors.js";
|
|
15
|
+
export { JSONSchemaGenerator } from "./json-schema-generator.js";
|
|
14
16
|
export * as JSONSchema from "./json-schema.js";
|