zod 3.25.3 → 3.25.5
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/dist/commonjs/v3/types.d.ts +38 -38
- package/dist/commonjs/v4/classic/errors.d.ts +1 -1
- package/dist/commonjs/v4/classic/errors.js +1 -0
- package/dist/commonjs/v4/classic/parse.d.ts +1 -1
- package/dist/commonjs/v4/classic/parse.js +2 -2
- package/dist/commonjs/v4/core/errors.d.ts +1 -1
- package/dist/commonjs/v4/core/errors.js +44 -0
- package/dist/commonjs/v4/core/parse.js +2 -2
- package/dist/esm/v3/types.d.ts +38 -38
- package/dist/esm/v4/classic/errors.d.ts +1 -1
- package/dist/esm/v4/classic/errors.js +1 -0
- package/dist/esm/v4/classic/parse.d.ts +1 -1
- package/dist/esm/v4/classic/parse.js +3 -3
- package/dist/esm/v4/core/errors.d.ts +1 -1
- package/dist/esm/v4/core/errors.js +11 -0
- package/dist/esm/v4/core/parse.js +2 -2
- package/package.json +1 -1
- package/src/v3/types.ts +50 -41
- package/src/v4/classic/errors.ts +2 -1
- package/src/v4/classic/parse.ts +3 -3
- package/src/v4/classic/tests/array.test.ts +42 -46
- package/src/v4/classic/tests/async-refinements.test.ts +14 -18
- package/src/v4/classic/tests/catch.test.ts +10 -12
- package/src/v4/classic/tests/discriminated-unions.test.ts +77 -87
- package/src/v4/classic/tests/enum.test.ts +33 -39
- package/src/v4/classic/tests/error-utils.test.ts +25 -27
- package/src/v4/classic/tests/error.test.ts +115 -128
- package/src/v4/classic/tests/literal.test.ts +10 -12
- package/src/v4/classic/tests/map.test.ts +60 -68
- package/src/v4/classic/tests/nested-refine.test.ts +68 -72
- package/src/v4/classic/tests/nonoptional.test.ts +36 -44
- package/src/v4/classic/tests/number.test.ts +36 -44
- package/src/v4/classic/tests/pipe.test.ts +18 -22
- package/src/v4/classic/tests/preprocess.test.ts +91 -107
- package/src/v4/classic/tests/primitive.test.ts +9 -11
- package/src/v4/classic/tests/record.test.ts +101 -121
- package/src/v4/classic/tests/set.test.ts +30 -36
- package/src/v4/classic/tests/string.test.ts +50 -60
- package/src/v4/classic/tests/template-literal.test.ts +45 -55
- package/src/v4/classic/tests/transform.test.ts +36 -46
- package/src/v4/classic/tests/tuple.test.ts +54 -66
- package/src/v4/core/errors.ts +12 -1
- package/src/v4/core/parse.ts +2 -2
- package/src/v4/core/tests/index.test.ts +42 -1
- package/src/v4/mini/tests/error.test.ts +1 -1
|
@@ -491,7 +491,7 @@ export declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCar
|
|
|
491
491
|
max(maxLength: number, message?: errorUtil.ErrMessage): this;
|
|
492
492
|
length(len: number, message?: errorUtil.ErrMessage): this;
|
|
493
493
|
nonempty(message?: errorUtil.ErrMessage): ZodArray<T, "atleastone">;
|
|
494
|
-
static create: <
|
|
494
|
+
static create: <El extends ZodTypeAny>(schema: El, params?: RawCreateParams) => ZodArray<El>;
|
|
495
495
|
}
|
|
496
496
|
export type ZodNonEmptyArray<T extends ZodTypeAny> = ZodArray<T, "atleastone">;
|
|
497
497
|
export type UnknownKeysParam = "passthrough" | "strict" | "strip";
|
|
@@ -584,9 +584,9 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
|
|
|
584
584
|
[k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
|
|
585
585
|
}>, UnknownKeys, Catchall>;
|
|
586
586
|
keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
|
|
587
|
-
static create: <
|
|
588
|
-
static strictCreate: <
|
|
589
|
-
static lazycreate: <
|
|
587
|
+
static create: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strip", ZodTypeAny, objectOutputType<Shape, ZodTypeAny, "strip">, objectInputType<Shape, ZodTypeAny, "strip">>;
|
|
588
|
+
static strictCreate: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strict">;
|
|
589
|
+
static lazycreate: <Shape extends ZodRawShape>(shape: () => Shape, params?: RawCreateParams) => ZodObject<Shape, "strip">;
|
|
590
590
|
}
|
|
591
591
|
export type AnyZodObject = ZodObject<any, any, any>;
|
|
592
592
|
export type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
|
|
@@ -597,7 +597,7 @@ export interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[ZodTypeAny, Z
|
|
|
597
597
|
export declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
|
|
598
598
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
599
599
|
get options(): T;
|
|
600
|
-
static create: <
|
|
600
|
+
static create: <Options extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>>(types: Options, params?: RawCreateParams) => ZodUnion<Options>;
|
|
601
601
|
}
|
|
602
602
|
export type ZodDiscriminatedUnionOption<Discriminator extends string> = ZodObject<{
|
|
603
603
|
[key in Discriminator]: ZodTypeAny;
|
|
@@ -633,7 +633,7 @@ export interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends
|
|
|
633
633
|
}
|
|
634
634
|
export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
|
|
635
635
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
636
|
-
static create: <
|
|
636
|
+
static create: <TSchema extends ZodTypeAny, USchema extends ZodTypeAny>(left: TSchema, right: USchema, params?: RawCreateParams) => ZodIntersection<TSchema, USchema>;
|
|
637
637
|
}
|
|
638
638
|
export type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
|
|
639
639
|
export type AssertArray<T> = T extends any[] ? T : never;
|
|
@@ -655,7 +655,7 @@ export declare class ZodTuple<T extends ZodTupleItems | [] = ZodTupleItems, Rest
|
|
|
655
655
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
656
656
|
get items(): T;
|
|
657
657
|
rest<Rest extends ZodTypeAny>(rest: Rest): ZodTuple<T, Rest>;
|
|
658
|
-
static create: <
|
|
658
|
+
static create: <Items extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: Items, params?: RawCreateParams) => ZodTuple<Items, null>;
|
|
659
659
|
}
|
|
660
660
|
export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
661
661
|
valueType: Value;
|
|
@@ -681,7 +681,7 @@ export declare class ZodMap<Key extends ZodTypeAny = ZodTypeAny, Value extends Z
|
|
|
681
681
|
get keySchema(): Key;
|
|
682
682
|
get valueSchema(): Value;
|
|
683
683
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
684
|
-
static create: <
|
|
684
|
+
static create: <KeySchema extends ZodTypeAny = ZodTypeAny, ValueSchema extends ZodTypeAny = ZodTypeAny>(keyType: KeySchema, valueType: ValueSchema, params?: RawCreateParams) => ZodMap<KeySchema, ValueSchema>;
|
|
685
685
|
}
|
|
686
686
|
export interface ZodSetDef<Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
687
687
|
valueType: Value;
|
|
@@ -701,7 +701,7 @@ export declare class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodTy
|
|
|
701
701
|
max(maxSize: number, message?: errorUtil.ErrMessage): this;
|
|
702
702
|
size(size: number, message?: errorUtil.ErrMessage): this;
|
|
703
703
|
nonempty(message?: errorUtil.ErrMessage): ZodSet<Value>;
|
|
704
|
-
static create: <
|
|
704
|
+
static create: <ValueSchema extends ZodTypeAny = ZodTypeAny>(valueType: ValueSchema, params?: RawCreateParams) => ZodSet<ValueSchema>;
|
|
705
705
|
}
|
|
706
706
|
export interface ZodFunctionDef<Args extends ZodTuple<any, any> = ZodTuple<any, any>, Returns extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
707
707
|
args: Args;
|
|
@@ -731,7 +731,7 @@ export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDe
|
|
|
731
731
|
export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, ZodLazyDef<T>, input<T>> {
|
|
732
732
|
get schema(): T;
|
|
733
733
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
734
|
-
static create: <
|
|
734
|
+
static create: <Inner extends ZodTypeAny>(getter: () => Inner, params?: RawCreateParams) => ZodLazy<Inner>;
|
|
735
735
|
}
|
|
736
736
|
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
|
|
737
737
|
value: T;
|
|
@@ -740,7 +740,7 @@ export interface ZodLiteralDef<T = any> extends ZodTypeDef {
|
|
|
740
740
|
export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>, T> {
|
|
741
741
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
742
742
|
get value(): T;
|
|
743
|
-
static create: <
|
|
743
|
+
static create: <Value extends Primitive>(value: Value, params?: RawCreateParams) => ZodLiteral<Value>;
|
|
744
744
|
}
|
|
745
745
|
export type ArrayKeys = keyof any[];
|
|
746
746
|
export type Indices<T> = Exclude<keyof T, ArrayKeys>;
|
|
@@ -782,7 +782,7 @@ export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T
|
|
|
782
782
|
#private;
|
|
783
783
|
_parse(input: ParseInput): ParseReturnType<T[keyof T]>;
|
|
784
784
|
get enum(): T;
|
|
785
|
-
static create: <
|
|
785
|
+
static create: <Elements extends EnumLike>(values: Elements, params?: RawCreateParams) => ZodNativeEnum<Elements>;
|
|
786
786
|
}
|
|
787
787
|
export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
788
788
|
type: T;
|
|
@@ -791,7 +791,7 @@ export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTyp
|
|
|
791
791
|
export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
|
|
792
792
|
unwrap(): T;
|
|
793
793
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
794
|
-
static create: <
|
|
794
|
+
static create: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
|
|
795
795
|
}
|
|
796
796
|
export type Refinement<T> = (arg: T, ctx: RefinementCtx) => any;
|
|
797
797
|
export type SuperRefinement<T> = (arg: T, ctx: RefinementCtx) => void | Promise<void>;
|
|
@@ -829,7 +829,7 @@ export type ZodOptionalType<T extends ZodTypeAny> = ZodOptional<T>;
|
|
|
829
829
|
export declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
|
|
830
830
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
831
831
|
unwrap(): T;
|
|
832
|
-
static create: <
|
|
832
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodOptional<Inner>;
|
|
833
833
|
}
|
|
834
834
|
export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
835
835
|
innerType: T;
|
|
@@ -839,7 +839,7 @@ export type ZodNullableType<T extends ZodTypeAny> = ZodNullable<T>;
|
|
|
839
839
|
export declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
|
|
840
840
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
841
841
|
unwrap(): T;
|
|
842
|
-
static create: <
|
|
842
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodNullable<Inner>;
|
|
843
843
|
}
|
|
844
844
|
export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
845
845
|
innerType: T;
|
|
@@ -849,9 +849,9 @@ export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTyp
|
|
|
849
849
|
export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodDefaultDef<T>, T["_input"] | undefined> {
|
|
850
850
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
851
851
|
removeDefault(): T;
|
|
852
|
-
static create: <
|
|
853
|
-
default:
|
|
854
|
-
}) => ZodDefault<
|
|
852
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params: RawCreateParams & {
|
|
853
|
+
default: Inner["_input"] | (() => util.noUndefined<Inner["_input"]>);
|
|
854
|
+
}) => ZodDefault<Inner>;
|
|
855
855
|
}
|
|
856
856
|
export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
857
857
|
innerType: T;
|
|
@@ -864,9 +864,9 @@ export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeD
|
|
|
864
864
|
export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
|
|
865
865
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
866
866
|
removeCatch(): T;
|
|
867
|
-
static create: <
|
|
868
|
-
catch:
|
|
869
|
-
}) => ZodCatch<
|
|
867
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params: RawCreateParams & {
|
|
868
|
+
catch: Inner["_output"] | (() => Inner["_output"]);
|
|
869
|
+
}) => ZodCatch<Inner>;
|
|
870
870
|
}
|
|
871
871
|
export interface ZodNaNDef extends ZodTypeDef {
|
|
872
872
|
typeName: ZodFirstPartyTypeKind.ZodNaN;
|
|
@@ -896,7 +896,7 @@ export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny> exte
|
|
|
896
896
|
}
|
|
897
897
|
export declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
|
|
898
898
|
_parse(input: ParseInput): ParseReturnType<any>;
|
|
899
|
-
static create<
|
|
899
|
+
static create<ASchema extends ZodTypeAny, BSchema extends ZodTypeAny>(a: ASchema, b: BSchema): ZodPipeline<ASchema, BSchema>;
|
|
900
900
|
}
|
|
901
901
|
type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
|
902
902
|
readonly [Symbol.toStringTag]: string;
|
|
@@ -908,7 +908,7 @@ export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTy
|
|
|
908
908
|
}
|
|
909
909
|
export declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, MakeReadonly<T["_input"]>> {
|
|
910
910
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
911
|
-
static create: <
|
|
911
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodReadonly<Inner>;
|
|
912
912
|
unwrap(): T;
|
|
913
913
|
}
|
|
914
914
|
type CustomParams = CustomErrorParams & {
|
|
@@ -928,7 +928,7 @@ export declare function custom<T>(check?: (data: any) => any, _params?: string |
|
|
|
928
928
|
fatal?: boolean): ZodType<T, ZodTypeDef, T>;
|
|
929
929
|
export { ZodType as Schema, ZodType as ZodSchema };
|
|
930
930
|
export declare const late: {
|
|
931
|
-
object: <
|
|
931
|
+
object: <Shape extends ZodRawShape>(shape: () => Shape, params?: RawCreateParams) => ZodObject<Shape, "strip">;
|
|
932
932
|
};
|
|
933
933
|
export declare enum ZodFirstPartyTypeKind {
|
|
934
934
|
ZodString = "ZodString",
|
|
@@ -996,25 +996,25 @@ declare const anyType: (params?: RawCreateParams) => ZodAny;
|
|
|
996
996
|
declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
|
|
997
997
|
declare const neverType: (params?: RawCreateParams) => ZodNever;
|
|
998
998
|
declare const voidType: (params?: RawCreateParams) => ZodVoid;
|
|
999
|
-
declare const arrayType: <
|
|
1000
|
-
declare const objectType: <
|
|
1001
|
-
declare const strictObjectType: <
|
|
1002
|
-
declare const unionType: <
|
|
999
|
+
declare const arrayType: <El extends ZodTypeAny>(schema: El, params?: RawCreateParams) => ZodArray<El>;
|
|
1000
|
+
declare const objectType: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strip", ZodTypeAny, objectOutputType<Shape, ZodTypeAny, "strip">, objectInputType<Shape, ZodTypeAny, "strip">>;
|
|
1001
|
+
declare const strictObjectType: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strict">;
|
|
1002
|
+
declare const unionType: <Options extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>>(types: Options, params?: RawCreateParams) => ZodUnion<Options>;
|
|
1003
1003
|
declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
|
|
1004
|
-
declare const intersectionType: <
|
|
1005
|
-
declare const tupleType: <
|
|
1004
|
+
declare const intersectionType: <TSchema extends ZodTypeAny, USchema extends ZodTypeAny>(left: TSchema, right: USchema, params?: RawCreateParams) => ZodIntersection<TSchema, USchema>;
|
|
1005
|
+
declare const tupleType: <Items extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: Items, params?: RawCreateParams) => ZodTuple<Items, null>;
|
|
1006
1006
|
declare const recordType: typeof ZodRecord.create;
|
|
1007
|
-
declare const mapType: <
|
|
1008
|
-
declare const setType: <
|
|
1007
|
+
declare const mapType: <KeySchema extends ZodTypeAny = ZodTypeAny, ValueSchema extends ZodTypeAny = ZodTypeAny>(keyType: KeySchema, valueType: ValueSchema, params?: RawCreateParams) => ZodMap<KeySchema, ValueSchema>;
|
|
1008
|
+
declare const setType: <ValueSchema extends ZodTypeAny = ZodTypeAny>(valueType: ValueSchema, params?: RawCreateParams) => ZodSet<ValueSchema>;
|
|
1009
1009
|
declare const functionType: typeof ZodFunction.create;
|
|
1010
|
-
declare const lazyType: <
|
|
1011
|
-
declare const literalType: <
|
|
1010
|
+
declare const lazyType: <Inner extends ZodTypeAny>(getter: () => Inner, params?: RawCreateParams) => ZodLazy<Inner>;
|
|
1011
|
+
declare const literalType: <Value extends Primitive>(value: Value, params?: RawCreateParams) => ZodLiteral<Value>;
|
|
1012
1012
|
declare const enumType: typeof createZodEnum;
|
|
1013
|
-
declare const nativeEnumType: <
|
|
1014
|
-
declare const promiseType: <
|
|
1013
|
+
declare const nativeEnumType: <Elements extends EnumLike>(values: Elements, params?: RawCreateParams) => ZodNativeEnum<Elements>;
|
|
1014
|
+
declare const promiseType: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
|
|
1015
1015
|
declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"]>;
|
|
1016
|
-
declare const optionalType: <
|
|
1017
|
-
declare const nullableType: <
|
|
1016
|
+
declare const optionalType: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodOptional<Inner>;
|
|
1017
|
+
declare const nullableType: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodNullable<Inner>;
|
|
1018
1018
|
declare const preprocessType: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
|
|
1019
1019
|
declare const pipelineType: typeof ZodPipeline.create;
|
|
1020
1020
|
declare const ostring: () => ZodOptional<ZodString>;
|
|
@@ -2,7 +2,7 @@ import * as core from "zod/v4/core";
|
|
|
2
2
|
import { $ZodError } from "zod/v4/core";
|
|
3
3
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
4
4
|
export type ZodIssue = core.$ZodIssue;
|
|
5
|
-
/** An Error-like class
|
|
5
|
+
/** An Error-like class used to store Zod validation issues. */
|
|
6
6
|
export interface ZodError<T = unknown> extends $ZodError<T> {
|
|
7
7
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
8
8
|
format(): core.$ZodFormattedError<T>;
|
|
@@ -38,6 +38,7 @@ const core = __importStar(require("zod/v4/core"));
|
|
|
38
38
|
const core_1 = require("zod/v4/core");
|
|
39
39
|
const initializer = (inst, issues) => {
|
|
40
40
|
core_1.$ZodError.init(inst, issues);
|
|
41
|
+
inst.name = "ZodError";
|
|
41
42
|
Object.defineProperties(inst, {
|
|
42
43
|
format: {
|
|
43
44
|
value: (mapper) => core.formatError(inst, mapper),
|
|
@@ -38,5 +38,5 @@ const core = __importStar(require("zod/v4/core"));
|
|
|
38
38
|
const errors_js_1 = require("./errors.js");
|
|
39
39
|
exports.parse = core._parse(errors_js_1.ZodRealError);
|
|
40
40
|
exports.parseAsync = core._parseAsync(errors_js_1.ZodRealError);
|
|
41
|
-
exports.safeParse = core._safeParse(errors_js_1.
|
|
42
|
-
exports.safeParseAsync = core._safeParseAsync(errors_js_1.
|
|
41
|
+
exports.safeParse = core._safeParse(errors_js_1.ZodRealError);
|
|
42
|
+
exports.safeParseAsync = core._safeParseAsync(errors_js_1.ZodRealError);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { $ZodCheck, $ZodStringFormats } from "./checks.js";
|
|
2
2
|
import { $constructor } from "./core.js";
|
|
3
3
|
import type { $ZodType } from "./schemas.js";
|
|
4
|
-
import
|
|
4
|
+
import * as util from "./util.js";
|
|
5
5
|
export interface $ZodIssueBase {
|
|
6
6
|
readonly code?: string;
|
|
7
7
|
readonly input?: unknown;
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.$ZodRealError = exports.$ZodError = void 0;
|
|
4
37
|
exports.flattenError = flattenError;
|
|
@@ -7,15 +40,26 @@ exports.treeifyError = treeifyError;
|
|
|
7
40
|
exports.toDotPath = toDotPath;
|
|
8
41
|
exports.prettifyError = prettifyError;
|
|
9
42
|
const core_js_1 = require("./core.js");
|
|
43
|
+
const util = __importStar(require("./util.js"));
|
|
10
44
|
const initializer = (inst, def) => {
|
|
45
|
+
inst.name = "$ZodError";
|
|
11
46
|
Object.defineProperty(inst, "_zod", {
|
|
12
47
|
value: inst._zod,
|
|
13
48
|
enumerable: false,
|
|
14
49
|
});
|
|
15
50
|
Object.defineProperty(inst, "issues", {
|
|
16
51
|
value: def,
|
|
52
|
+
enumerable: false,
|
|
53
|
+
});
|
|
54
|
+
// inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);
|
|
55
|
+
Object.defineProperty(inst, "message", {
|
|
56
|
+
get() {
|
|
57
|
+
return JSON.stringify(def, util.jsonStringifyReplacer, 2);
|
|
58
|
+
},
|
|
17
59
|
enumerable: true,
|
|
60
|
+
// configurable: false,
|
|
18
61
|
});
|
|
62
|
+
// inst.toString = () => inst.message;
|
|
19
63
|
// inst.message = `Invalid input`;
|
|
20
64
|
// Object.defineProperty(inst, "message", {
|
|
21
65
|
// get() {
|
|
@@ -80,7 +80,7 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
80
80
|
: { success: true, data: result.value };
|
|
81
81
|
};
|
|
82
82
|
exports._safeParse = _safeParse;
|
|
83
|
-
exports.safeParse = (0, exports._safeParse)(errors.$
|
|
83
|
+
exports.safeParse = (0, exports._safeParse)(errors.$ZodRealError);
|
|
84
84
|
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
85
85
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
86
86
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -94,4 +94,4 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
94
94
|
: { success: true, data: result.value };
|
|
95
95
|
};
|
|
96
96
|
exports._safeParseAsync = _safeParseAsync;
|
|
97
|
-
exports.safeParseAsync = (0, exports._safeParseAsync)(errors.$
|
|
97
|
+
exports.safeParseAsync = (0, exports._safeParseAsync)(errors.$ZodRealError);
|
package/dist/esm/v3/types.d.ts
CHANGED
|
@@ -491,7 +491,7 @@ export declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCar
|
|
|
491
491
|
max(maxLength: number, message?: errorUtil.ErrMessage): this;
|
|
492
492
|
length(len: number, message?: errorUtil.ErrMessage): this;
|
|
493
493
|
nonempty(message?: errorUtil.ErrMessage): ZodArray<T, "atleastone">;
|
|
494
|
-
static create: <
|
|
494
|
+
static create: <El extends ZodTypeAny>(schema: El, params?: RawCreateParams) => ZodArray<El>;
|
|
495
495
|
}
|
|
496
496
|
export type ZodNonEmptyArray<T extends ZodTypeAny> = ZodArray<T, "atleastone">;
|
|
497
497
|
export type UnknownKeysParam = "passthrough" | "strict" | "strip";
|
|
@@ -584,9 +584,9 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
|
|
|
584
584
|
[k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
|
|
585
585
|
}>, UnknownKeys, Catchall>;
|
|
586
586
|
keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
|
|
587
|
-
static create: <
|
|
588
|
-
static strictCreate: <
|
|
589
|
-
static lazycreate: <
|
|
587
|
+
static create: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strip", ZodTypeAny, objectOutputType<Shape, ZodTypeAny, "strip">, objectInputType<Shape, ZodTypeAny, "strip">>;
|
|
588
|
+
static strictCreate: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strict">;
|
|
589
|
+
static lazycreate: <Shape extends ZodRawShape>(shape: () => Shape, params?: RawCreateParams) => ZodObject<Shape, "strip">;
|
|
590
590
|
}
|
|
591
591
|
export type AnyZodObject = ZodObject<any, any, any>;
|
|
592
592
|
export type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
|
|
@@ -597,7 +597,7 @@ export interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[ZodTypeAny, Z
|
|
|
597
597
|
export declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
|
|
598
598
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
599
599
|
get options(): T;
|
|
600
|
-
static create: <
|
|
600
|
+
static create: <Options extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>>(types: Options, params?: RawCreateParams) => ZodUnion<Options>;
|
|
601
601
|
}
|
|
602
602
|
export type ZodDiscriminatedUnionOption<Discriminator extends string> = ZodObject<{
|
|
603
603
|
[key in Discriminator]: ZodTypeAny;
|
|
@@ -633,7 +633,7 @@ export interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends
|
|
|
633
633
|
}
|
|
634
634
|
export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
|
|
635
635
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
636
|
-
static create: <
|
|
636
|
+
static create: <TSchema extends ZodTypeAny, USchema extends ZodTypeAny>(left: TSchema, right: USchema, params?: RawCreateParams) => ZodIntersection<TSchema, USchema>;
|
|
637
637
|
}
|
|
638
638
|
export type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
|
|
639
639
|
export type AssertArray<T> = T extends any[] ? T : never;
|
|
@@ -655,7 +655,7 @@ export declare class ZodTuple<T extends ZodTupleItems | [] = ZodTupleItems, Rest
|
|
|
655
655
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
656
656
|
get items(): T;
|
|
657
657
|
rest<Rest extends ZodTypeAny>(rest: Rest): ZodTuple<T, Rest>;
|
|
658
|
-
static create: <
|
|
658
|
+
static create: <Items extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: Items, params?: RawCreateParams) => ZodTuple<Items, null>;
|
|
659
659
|
}
|
|
660
660
|
export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
661
661
|
valueType: Value;
|
|
@@ -681,7 +681,7 @@ export declare class ZodMap<Key extends ZodTypeAny = ZodTypeAny, Value extends Z
|
|
|
681
681
|
get keySchema(): Key;
|
|
682
682
|
get valueSchema(): Value;
|
|
683
683
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
684
|
-
static create: <
|
|
684
|
+
static create: <KeySchema extends ZodTypeAny = ZodTypeAny, ValueSchema extends ZodTypeAny = ZodTypeAny>(keyType: KeySchema, valueType: ValueSchema, params?: RawCreateParams) => ZodMap<KeySchema, ValueSchema>;
|
|
685
685
|
}
|
|
686
686
|
export interface ZodSetDef<Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
687
687
|
valueType: Value;
|
|
@@ -701,7 +701,7 @@ export declare class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodTy
|
|
|
701
701
|
max(maxSize: number, message?: errorUtil.ErrMessage): this;
|
|
702
702
|
size(size: number, message?: errorUtil.ErrMessage): this;
|
|
703
703
|
nonempty(message?: errorUtil.ErrMessage): ZodSet<Value>;
|
|
704
|
-
static create: <
|
|
704
|
+
static create: <ValueSchema extends ZodTypeAny = ZodTypeAny>(valueType: ValueSchema, params?: RawCreateParams) => ZodSet<ValueSchema>;
|
|
705
705
|
}
|
|
706
706
|
export interface ZodFunctionDef<Args extends ZodTuple<any, any> = ZodTuple<any, any>, Returns extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
707
707
|
args: Args;
|
|
@@ -731,7 +731,7 @@ export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDe
|
|
|
731
731
|
export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, ZodLazyDef<T>, input<T>> {
|
|
732
732
|
get schema(): T;
|
|
733
733
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
734
|
-
static create: <
|
|
734
|
+
static create: <Inner extends ZodTypeAny>(getter: () => Inner, params?: RawCreateParams) => ZodLazy<Inner>;
|
|
735
735
|
}
|
|
736
736
|
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
|
|
737
737
|
value: T;
|
|
@@ -740,7 +740,7 @@ export interface ZodLiteralDef<T = any> extends ZodTypeDef {
|
|
|
740
740
|
export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>, T> {
|
|
741
741
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
742
742
|
get value(): T;
|
|
743
|
-
static create: <
|
|
743
|
+
static create: <Value extends Primitive>(value: Value, params?: RawCreateParams) => ZodLiteral<Value>;
|
|
744
744
|
}
|
|
745
745
|
export type ArrayKeys = keyof any[];
|
|
746
746
|
export type Indices<T> = Exclude<keyof T, ArrayKeys>;
|
|
@@ -782,7 +782,7 @@ export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T
|
|
|
782
782
|
#private;
|
|
783
783
|
_parse(input: ParseInput): ParseReturnType<T[keyof T]>;
|
|
784
784
|
get enum(): T;
|
|
785
|
-
static create: <
|
|
785
|
+
static create: <Elements extends EnumLike>(values: Elements, params?: RawCreateParams) => ZodNativeEnum<Elements>;
|
|
786
786
|
}
|
|
787
787
|
export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
788
788
|
type: T;
|
|
@@ -791,7 +791,7 @@ export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTyp
|
|
|
791
791
|
export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
|
|
792
792
|
unwrap(): T;
|
|
793
793
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
794
|
-
static create: <
|
|
794
|
+
static create: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
|
|
795
795
|
}
|
|
796
796
|
export type Refinement<T> = (arg: T, ctx: RefinementCtx) => any;
|
|
797
797
|
export type SuperRefinement<T> = (arg: T, ctx: RefinementCtx) => void | Promise<void>;
|
|
@@ -829,7 +829,7 @@ export type ZodOptionalType<T extends ZodTypeAny> = ZodOptional<T>;
|
|
|
829
829
|
export declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
|
|
830
830
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
831
831
|
unwrap(): T;
|
|
832
|
-
static create: <
|
|
832
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodOptional<Inner>;
|
|
833
833
|
}
|
|
834
834
|
export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
835
835
|
innerType: T;
|
|
@@ -839,7 +839,7 @@ export type ZodNullableType<T extends ZodTypeAny> = ZodNullable<T>;
|
|
|
839
839
|
export declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
|
|
840
840
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
841
841
|
unwrap(): T;
|
|
842
|
-
static create: <
|
|
842
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodNullable<Inner>;
|
|
843
843
|
}
|
|
844
844
|
export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
845
845
|
innerType: T;
|
|
@@ -849,9 +849,9 @@ export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTyp
|
|
|
849
849
|
export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodDefaultDef<T>, T["_input"] | undefined> {
|
|
850
850
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
851
851
|
removeDefault(): T;
|
|
852
|
-
static create: <
|
|
853
|
-
default:
|
|
854
|
-
}) => ZodDefault<
|
|
852
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params: RawCreateParams & {
|
|
853
|
+
default: Inner["_input"] | (() => util.noUndefined<Inner["_input"]>);
|
|
854
|
+
}) => ZodDefault<Inner>;
|
|
855
855
|
}
|
|
856
856
|
export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
857
857
|
innerType: T;
|
|
@@ -864,9 +864,9 @@ export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeD
|
|
|
864
864
|
export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
|
|
865
865
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
866
866
|
removeCatch(): T;
|
|
867
|
-
static create: <
|
|
868
|
-
catch:
|
|
869
|
-
}) => ZodCatch<
|
|
867
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params: RawCreateParams & {
|
|
868
|
+
catch: Inner["_output"] | (() => Inner["_output"]);
|
|
869
|
+
}) => ZodCatch<Inner>;
|
|
870
870
|
}
|
|
871
871
|
export interface ZodNaNDef extends ZodTypeDef {
|
|
872
872
|
typeName: ZodFirstPartyTypeKind.ZodNaN;
|
|
@@ -896,7 +896,7 @@ export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny> exte
|
|
|
896
896
|
}
|
|
897
897
|
export declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
|
|
898
898
|
_parse(input: ParseInput): ParseReturnType<any>;
|
|
899
|
-
static create<
|
|
899
|
+
static create<ASchema extends ZodTypeAny, BSchema extends ZodTypeAny>(a: ASchema, b: BSchema): ZodPipeline<ASchema, BSchema>;
|
|
900
900
|
}
|
|
901
901
|
type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
|
902
902
|
readonly [Symbol.toStringTag]: string;
|
|
@@ -908,7 +908,7 @@ export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTy
|
|
|
908
908
|
}
|
|
909
909
|
export declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, MakeReadonly<T["_input"]>> {
|
|
910
910
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
911
|
-
static create: <
|
|
911
|
+
static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodReadonly<Inner>;
|
|
912
912
|
unwrap(): T;
|
|
913
913
|
}
|
|
914
914
|
type CustomParams = CustomErrorParams & {
|
|
@@ -928,7 +928,7 @@ export declare function custom<T>(check?: (data: any) => any, _params?: string |
|
|
|
928
928
|
fatal?: boolean): ZodType<T, ZodTypeDef, T>;
|
|
929
929
|
export { ZodType as Schema, ZodType as ZodSchema };
|
|
930
930
|
export declare const late: {
|
|
931
|
-
object: <
|
|
931
|
+
object: <Shape extends ZodRawShape>(shape: () => Shape, params?: RawCreateParams) => ZodObject<Shape, "strip">;
|
|
932
932
|
};
|
|
933
933
|
export declare enum ZodFirstPartyTypeKind {
|
|
934
934
|
ZodString = "ZodString",
|
|
@@ -996,25 +996,25 @@ declare const anyType: (params?: RawCreateParams) => ZodAny;
|
|
|
996
996
|
declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
|
|
997
997
|
declare const neverType: (params?: RawCreateParams) => ZodNever;
|
|
998
998
|
declare const voidType: (params?: RawCreateParams) => ZodVoid;
|
|
999
|
-
declare const arrayType: <
|
|
1000
|
-
declare const objectType: <
|
|
1001
|
-
declare const strictObjectType: <
|
|
1002
|
-
declare const unionType: <
|
|
999
|
+
declare const arrayType: <El extends ZodTypeAny>(schema: El, params?: RawCreateParams) => ZodArray<El>;
|
|
1000
|
+
declare const objectType: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strip", ZodTypeAny, objectOutputType<Shape, ZodTypeAny, "strip">, objectInputType<Shape, ZodTypeAny, "strip">>;
|
|
1001
|
+
declare const strictObjectType: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strict">;
|
|
1002
|
+
declare const unionType: <Options extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>>(types: Options, params?: RawCreateParams) => ZodUnion<Options>;
|
|
1003
1003
|
declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
|
|
1004
|
-
declare const intersectionType: <
|
|
1005
|
-
declare const tupleType: <
|
|
1004
|
+
declare const intersectionType: <TSchema extends ZodTypeAny, USchema extends ZodTypeAny>(left: TSchema, right: USchema, params?: RawCreateParams) => ZodIntersection<TSchema, USchema>;
|
|
1005
|
+
declare const tupleType: <Items extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: Items, params?: RawCreateParams) => ZodTuple<Items, null>;
|
|
1006
1006
|
declare const recordType: typeof ZodRecord.create;
|
|
1007
|
-
declare const mapType: <
|
|
1008
|
-
declare const setType: <
|
|
1007
|
+
declare const mapType: <KeySchema extends ZodTypeAny = ZodTypeAny, ValueSchema extends ZodTypeAny = ZodTypeAny>(keyType: KeySchema, valueType: ValueSchema, params?: RawCreateParams) => ZodMap<KeySchema, ValueSchema>;
|
|
1008
|
+
declare const setType: <ValueSchema extends ZodTypeAny = ZodTypeAny>(valueType: ValueSchema, params?: RawCreateParams) => ZodSet<ValueSchema>;
|
|
1009
1009
|
declare const functionType: typeof ZodFunction.create;
|
|
1010
|
-
declare const lazyType: <
|
|
1011
|
-
declare const literalType: <
|
|
1010
|
+
declare const lazyType: <Inner extends ZodTypeAny>(getter: () => Inner, params?: RawCreateParams) => ZodLazy<Inner>;
|
|
1011
|
+
declare const literalType: <Value extends Primitive>(value: Value, params?: RawCreateParams) => ZodLiteral<Value>;
|
|
1012
1012
|
declare const enumType: typeof createZodEnum;
|
|
1013
|
-
declare const nativeEnumType: <
|
|
1014
|
-
declare const promiseType: <
|
|
1013
|
+
declare const nativeEnumType: <Elements extends EnumLike>(values: Elements, params?: RawCreateParams) => ZodNativeEnum<Elements>;
|
|
1014
|
+
declare const promiseType: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
|
|
1015
1015
|
declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"]>;
|
|
1016
|
-
declare const optionalType: <
|
|
1017
|
-
declare const nullableType: <
|
|
1016
|
+
declare const optionalType: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodOptional<Inner>;
|
|
1017
|
+
declare const nullableType: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodNullable<Inner>;
|
|
1018
1018
|
declare const preprocessType: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
|
|
1019
1019
|
declare const pipelineType: typeof ZodPipeline.create;
|
|
1020
1020
|
declare const ostring: () => ZodOptional<ZodString>;
|
|
@@ -2,7 +2,7 @@ import * as core from "zod/v4/core";
|
|
|
2
2
|
import { $ZodError } from "zod/v4/core";
|
|
3
3
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
4
4
|
export type ZodIssue = core.$ZodIssue;
|
|
5
|
-
/** An Error-like class
|
|
5
|
+
/** An Error-like class used to store Zod validation issues. */
|
|
6
6
|
export interface ZodError<T = unknown> extends $ZodError<T> {
|
|
7
7
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
8
8
|
format(): core.$ZodFormattedError<T>;
|
|
@@ -2,6 +2,7 @@ import * as core from "zod/v4/core";
|
|
|
2
2
|
import { $ZodError } from "zod/v4/core";
|
|
3
3
|
const initializer = (inst, issues) => {
|
|
4
4
|
$ZodError.init(inst, issues);
|
|
5
|
+
inst.name = "ZodError";
|
|
5
6
|
Object.defineProperties(inst, {
|
|
6
7
|
format: {
|
|
7
8
|
value: (mapper) => core.formatError(inst, mapper),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as core from "zod/v4/core";
|
|
2
|
-
import {
|
|
2
|
+
import { ZodRealError } from "./errors.js";
|
|
3
3
|
export const parse = /* @__PURE__ */ core._parse(ZodRealError);
|
|
4
4
|
export const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);
|
|
5
|
-
export const safeParse = /* @__PURE__ */ core._safeParse(
|
|
6
|
-
export const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(
|
|
5
|
+
export const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);
|
|
6
|
+
export const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { $ZodCheck, $ZodStringFormats } from "./checks.js";
|
|
2
2
|
import { $constructor } from "./core.js";
|
|
3
3
|
import type { $ZodType } from "./schemas.js";
|
|
4
|
-
import
|
|
4
|
+
import * as util from "./util.js";
|
|
5
5
|
export interface $ZodIssueBase {
|
|
6
6
|
readonly code?: string;
|
|
7
7
|
readonly input?: unknown;
|