zod 3.13.4 → 3.14.2
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/README.md +5 -4
- package/lib/ZodError.js +110 -205
- package/lib/benchmarks/discriminatedUnion.js +25 -25
- package/lib/benchmarks/index.js +15 -53
- package/lib/benchmarks/object.js +23 -23
- package/lib/benchmarks/primitives.d.ts +5 -0
- package/lib/benchmarks/primitives.js +78 -0
- package/lib/benchmarks/realworld.d.ts +5 -0
- package/lib/benchmarks/realworld.js +56 -0
- package/lib/benchmarks/string.js +27 -16
- package/lib/benchmarks/union.js +25 -25
- package/lib/helpers/errorUtil.js +2 -6
- package/lib/helpers/parseUtil.d.ts +7 -5
- package/lib/helpers/parseUtil.js +84 -244
- package/lib/helpers/util.js +20 -66
- package/lib/index.js +1 -1
- package/lib/index.mjs +1636 -2167
- package/lib/types.d.ts +6 -4
- package/lib/types.js +1422 -1772
- package/package.json +16 -14
package/lib/types.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export declare abstract class ZodType<Output, Def extends ZodTypeDef = ZodTypeDe
|
|
|
51
51
|
readonly _def: Def;
|
|
52
52
|
get description(): string | undefined;
|
|
53
53
|
abstract _parse(input: ParseInput): ParseReturnType<Output>;
|
|
54
|
+
_getType(input: ParseInput): string;
|
|
55
|
+
_getOrReturnCtx(input: ParseInput, ctx?: ParseContext | undefined): ParseContext;
|
|
54
56
|
_processInputParams(input: ParseInput): {
|
|
55
57
|
status: ParseStatus;
|
|
56
58
|
ctx: ParseContext;
|
|
@@ -439,7 +441,7 @@ export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny>
|
|
|
439
441
|
static create: <T_1 extends ZodTypeAny, U_1 extends ZodTypeAny>(left: T_1, right: U_1, params?: RawCreateParams) => ZodIntersection<T_1, U_1>;
|
|
440
442
|
}
|
|
441
443
|
export declare type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
|
|
442
|
-
export declare type AssertArray<T
|
|
444
|
+
export declare type AssertArray<T> = T extends any[] ? T : never;
|
|
443
445
|
export declare type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
|
|
444
446
|
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
|
|
445
447
|
}>;
|
|
@@ -530,11 +532,11 @@ export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, Zo
|
|
|
530
532
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
531
533
|
static create: <T_1 extends ZodTypeAny>(getter: () => T_1, params?: RawCreateParams) => ZodLazy<T_1>;
|
|
532
534
|
}
|
|
533
|
-
export interface ZodLiteralDef<T
|
|
535
|
+
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
|
|
534
536
|
value: T;
|
|
535
537
|
typeName: ZodFirstPartyTypeKind.ZodLiteral;
|
|
536
538
|
}
|
|
537
|
-
export declare class ZodLiteral<T
|
|
539
|
+
export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
|
|
538
540
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
539
541
|
get value(): T;
|
|
540
542
|
static create: <T_1 extends Primitive>(value: T_1, params?: RawCreateParams) => ZodLiteral<T_1>;
|
|
@@ -685,7 +687,7 @@ export declare enum ZodFirstPartyTypeKind {
|
|
|
685
687
|
ZodDefault = "ZodDefault",
|
|
686
688
|
ZodPromise = "ZodPromise"
|
|
687
689
|
}
|
|
688
|
-
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any, any, any> | ZodUnion<any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodPromise<any>;
|
|
690
|
+
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<any, any, any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodPromise<any>;
|
|
689
691
|
declare const instanceOfType: <T extends new (...args: any[]) => any>(cls: T, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
|
|
690
692
|
declare const stringType: (params?: RawCreateParams) => ZodString;
|
|
691
693
|
declare const numberType: (params?: RawCreateParams) => ZodNumber;
|