UNPKG

56 kBTypeScriptView Raw
1import { enumUtil } from "./helpers/enumUtil";
2import { errorUtil } from "./helpers/errorUtil";
3import { AsyncParseReturnType, ParseContext, ParseInput, ParseParams, ParseReturnType, ParseStatus, SyncParseReturnType } from "./helpers/parseUtil";
4import { partialUtil } from "./helpers/partialUtil";
5import { Primitive } from "./helpers/typeAliases";
6import { objectUtil, util } from "./helpers/util";
7import { IssueData, StringValidation, ZodCustomIssue, ZodError, ZodErrorMap } from "./ZodError";
8export interface RefinementCtx {
9 addIssue: (arg: IssueData) => void;
10 path: (string | number)[];
11}
12export declare type ZodRawShape = {
13 [k: string]: ZodTypeAny;
14};
15export declare type ZodTypeAny = ZodType<any, any, any>;
16export declare type TypeOf<T extends ZodType<any, any, any>> = T["_output"];
17export declare type input<T extends ZodType<any, any, any>> = T["_input"];
18export declare type output<T extends ZodType<any, any, any>> = T["_output"];
19export type { TypeOf as infer };
20export declare type CustomErrorParams = Partial<util.Omit<ZodCustomIssue, "code">>;
21export interface ZodTypeDef {
22 errorMap?: ZodErrorMap;
23 description?: string;
24}
25export declare type RawCreateParams = {
26 errorMap?: ZodErrorMap;
27 invalid_type_error?: string;
28 required_error?: string;
29 message?: string;
30 description?: string;
31} | undefined;
32export declare type ProcessedCreateParams = {
33 errorMap?: ZodErrorMap;
34 description?: string;
35};
36export declare type SafeParseSuccess<Output> = {
37 success: true;
38 data: Output;
39 error?: never;
40};
41export declare type SafeParseError<Input> = {
42 success: false;
43 error: ZodError<Input>;
44 data?: never;
45};
46export declare type SafeParseReturnType<Input, Output> = SafeParseSuccess<Output> | SafeParseError<Input>;
47export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
48 readonly _type: Output;
49 readonly _output: Output;
50 readonly _input: Input;
51 readonly _def: Def;
52 get description(): string | undefined;
53 abstract _parse(input: ParseInput): ParseReturnType<Output>;
54 _getType(input: ParseInput): string;
55 _getOrReturnCtx(input: ParseInput, ctx?: ParseContext | undefined): ParseContext;
56 _processInputParams(input: ParseInput): {
57 status: ParseStatus;
58 ctx: ParseContext;
59 };
60 _parseSync(input: ParseInput): SyncParseReturnType<Output>;
61 _parseAsync(input: ParseInput): AsyncParseReturnType<Output>;
62 parse(data: unknown, params?: Partial<ParseParams>): Output;
63 safeParse(data: unknown, params?: Partial<ParseParams>): SafeParseReturnType<Input, Output>;
64 parseAsync(data: unknown, params?: Partial<ParseParams>): Promise<Output>;
65 safeParseAsync(data: unknown, params?: Partial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>;
66 /** Alias of safeParseAsync */
67 spa: (data: unknown, params?: Partial<ParseParams> | undefined) => Promise<SafeParseReturnType<Input, Output>>;
68 refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, Input>;
69 refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>;
70 refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, Input>;
71 refinement(check: (arg: Output) => boolean, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, Output, Input>;
72 _refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>;
73 superRefine<RefinedOutput extends Output>(refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput): ZodEffects<this, RefinedOutput, Input>;
74 superRefine(refinement: (arg: Output, ctx: RefinementCtx) => void): ZodEffects<this, Output, Input>;
75 superRefine(refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>): ZodEffects<this, Output, Input>;
76 constructor(def: Def);
77 optional(): ZodOptional<this>;
78 nullable(): ZodNullable<this>;
79 nullish(): ZodOptional<ZodNullable<this>>;
80 array(): ZodArray<this>;
81 promise(): ZodPromise<this>;
82 or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>;
83 and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>;
84 transform<NewOut>(transform: (arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>;
85 default(def: util.noUndefined<Input>): ZodDefault<this>;
86 default(def: () => util.noUndefined<Input>): ZodDefault<this>;
87 brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
88 catch(def: Output): ZodCatch<this>;
89 catch(def: (ctx: {
90 error: ZodError;
91 input: Input;
92 }) => Output): ZodCatch<this>;
93 describe(description: string): this;
94 pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
95 readonly(): ZodReadonly<this>;
96 isOptional(): boolean;
97 isNullable(): boolean;
98}
99export declare type IpVersion = "v4" | "v6";
100export declare type ZodStringCheck = {
101 kind: "min";
102 value: number;
103 message?: string;
104} | {
105 kind: "max";
106 value: number;
107 message?: string;
108} | {
109 kind: "length";
110 value: number;
111 message?: string;
112} | {
113 kind: "email";
114 message?: string;
115} | {
116 kind: "url";
117 message?: string;
118} | {
119 kind: "emoji";
120 message?: string;
121} | {
122 kind: "uuid";
123 message?: string;
124} | {
125 kind: "nanoid";
126 message?: string;
127} | {
128 kind: "cuid";
129 message?: string;
130} | {
131 kind: "includes";
132 value: string;
133 position?: number;
134 message?: string;
135} | {
136 kind: "cuid2";
137 message?: string;
138} | {
139 kind: "ulid";
140 message?: string;
141} | {
142 kind: "startsWith";
143 value: string;
144 message?: string;
145} | {
146 kind: "endsWith";
147 value: string;
148 message?: string;
149} | {
150 kind: "regex";
151 regex: RegExp;
152 message?: string;
153} | {
154 kind: "trim";
155 message?: string;
156} | {
157 kind: "toLowerCase";
158 message?: string;
159} | {
160 kind: "toUpperCase";
161 message?: string;
162} | {
163 kind: "datetime";
164 offset: boolean;
165 local: boolean;
166 precision: number | null;
167 message?: string;
168} | {
169 kind: "date";
170 message?: string;
171} | {
172 kind: "time";
173 precision: number | null;
174 message?: string;
175} | {
176 kind: "duration";
177 message?: string;
178} | {
179 kind: "ip";
180 version?: IpVersion;
181 message?: string;
182} | {
183 kind: "base64";
184 message?: string;
185};
186export interface ZodStringDef extends ZodTypeDef {
187 checks: ZodStringCheck[];
188 typeName: ZodFirstPartyTypeKind.ZodString;
189 coerce: boolean;
190}
191export declare function datetimeRegex(args: {
192 precision?: number | null;
193 offset?: boolean;
194 local?: boolean;
195}): RegExp;
196export declare class ZodString extends ZodType<string, ZodStringDef, string> {
197 _parse(input: ParseInput): ParseReturnType<string>;
198 protected _regex(regex: RegExp, validation: StringValidation, message?: errorUtil.ErrMessage): ZodEffects<this, string, string>;
199 _addCheck(check: ZodStringCheck): ZodString;
200 email(message?: errorUtil.ErrMessage): ZodString;
201 url(message?: errorUtil.ErrMessage): ZodString;
202 emoji(message?: errorUtil.ErrMessage): ZodString;
203 uuid(message?: errorUtil.ErrMessage): ZodString;
204 nanoid(message?: errorUtil.ErrMessage): ZodString;
205 cuid(message?: errorUtil.ErrMessage): ZodString;
206 cuid2(message?: errorUtil.ErrMessage): ZodString;
207 ulid(message?: errorUtil.ErrMessage): ZodString;
208 base64(message?: errorUtil.ErrMessage): ZodString;
209 ip(options?: string | {
210 version?: "v4" | "v6";
211 message?: string;
212 }): ZodString;
213 datetime(options?: string | {
214 message?: string | undefined;
215 precision?: number | null;
216 offset?: boolean;
217 local?: boolean;
218 }): ZodString;
219 date(message?: string): ZodString;
220 time(options?: string | {
221 message?: string | undefined;
222 precision?: number | null;
223 }): ZodString;
224 duration(message?: errorUtil.ErrMessage): ZodString;
225 regex(regex: RegExp, message?: errorUtil.ErrMessage): ZodString;
226 includes(value: string, options?: {
227 message?: string;
228 position?: number;
229 }): ZodString;
230 startsWith(value: string, message?: errorUtil.ErrMessage): ZodString;
231 endsWith(value: string, message?: errorUtil.ErrMessage): ZodString;
232 min(minLength: number, message?: errorUtil.ErrMessage): ZodString;
233 max(maxLength: number, message?: errorUtil.ErrMessage): ZodString;
234 length(len: number, message?: errorUtil.ErrMessage): ZodString;
235 /**
236 * @deprecated Use z.string().min(1) instead.
237 * @see {@link ZodString.min}
238 */
239 nonempty(message?: errorUtil.ErrMessage): ZodString;
240 trim(): ZodString;
241 toLowerCase(): ZodString;
242 toUpperCase(): ZodString;
243 get isDatetime(): boolean;
244 get isDate(): boolean;
245 get isTime(): boolean;
246 get isDuration(): boolean;
247 get isEmail(): boolean;
248 get isURL(): boolean;
249 get isEmoji(): boolean;
250 get isUUID(): boolean;
251 get isNANOID(): boolean;
252 get isCUID(): boolean;
253 get isCUID2(): boolean;
254 get isULID(): boolean;
255 get isIP(): boolean;
256 get isBase64(): boolean;
257 get minLength(): number | null;
258 get maxLength(): number | null;
259 static create: (params?: ({
260 errorMap?: ZodErrorMap | undefined;
261 invalid_type_error?: string | undefined;
262 required_error?: string | undefined;
263 message?: string | undefined;
264 description?: string | undefined;
265 } & {
266 coerce?: true | undefined;
267 }) | undefined) => ZodString;
268}
269export declare type ZodNumberCheck = {
270 kind: "min";
271 value: number;
272 inclusive: boolean;
273 message?: string;
274} | {
275 kind: "max";
276 value: number;
277 inclusive: boolean;
278 message?: string;
279} | {
280 kind: "int";
281 message?: string;
282} | {
283 kind: "multipleOf";
284 value: number;
285 message?: string;
286} | {
287 kind: "finite";
288 message?: string;
289};
290export interface ZodNumberDef extends ZodTypeDef {
291 checks: ZodNumberCheck[];
292 typeName: ZodFirstPartyTypeKind.ZodNumber;
293 coerce: boolean;
294}
295export declare class ZodNumber extends ZodType<number, ZodNumberDef, number> {
296 _parse(input: ParseInput): ParseReturnType<number>;
297 static create: (params?: ({
298 errorMap?: ZodErrorMap | undefined;
299 invalid_type_error?: string | undefined;
300 required_error?: string | undefined;
301 message?: string | undefined;
302 description?: string | undefined;
303 } & {
304 coerce?: boolean | undefined;
305 }) | undefined) => ZodNumber;
306 gte(value: number, message?: errorUtil.ErrMessage): ZodNumber;
307 min: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
308 gt(value: number, message?: errorUtil.ErrMessage): ZodNumber;
309 lte(value: number, message?: errorUtil.ErrMessage): ZodNumber;
310 max: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
311 lt(value: number, message?: errorUtil.ErrMessage): ZodNumber;
312 protected setLimit(kind: "min" | "max", value: number, inclusive: boolean, message?: string): ZodNumber;
313 _addCheck(check: ZodNumberCheck): ZodNumber;
314 int(message?: errorUtil.ErrMessage): ZodNumber;
315 positive(message?: errorUtil.ErrMessage): ZodNumber;
316 negative(message?: errorUtil.ErrMessage): ZodNumber;
317 nonpositive(message?: errorUtil.ErrMessage): ZodNumber;
318 nonnegative(message?: errorUtil.ErrMessage): ZodNumber;
319 multipleOf(value: number, message?: errorUtil.ErrMessage): ZodNumber;
320 step: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
321 finite(message?: errorUtil.ErrMessage): ZodNumber;
322 safe(message?: errorUtil.ErrMessage): ZodNumber;
323 get minValue(): number | null;
324 get maxValue(): number | null;
325 get isInt(): boolean;
326 get isFinite(): boolean;
327}
328export declare type ZodBigIntCheck = {
329 kind: "min";
330 value: bigint;
331 inclusive: boolean;
332 message?: string;
333} | {
334 kind: "max";
335 value: bigint;
336 inclusive: boolean;
337 message?: string;
338} | {
339 kind: "multipleOf";
340 value: bigint;
341 message?: string;
342};
343export interface ZodBigIntDef extends ZodTypeDef {
344 checks: ZodBigIntCheck[];
345 typeName: ZodFirstPartyTypeKind.ZodBigInt;
346 coerce: boolean;
347}
348export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef, bigint> {
349 _parse(input: ParseInput): ParseReturnType<bigint>;
350 static create: (params?: ({
351 errorMap?: ZodErrorMap | undefined;
352 invalid_type_error?: string | undefined;
353 required_error?: string | undefined;
354 message?: string | undefined;
355 description?: string | undefined;
356 } & {
357 coerce?: boolean | undefined;
358 }) | undefined) => ZodBigInt;
359 gte(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
360 min: (value: bigint, message?: errorUtil.ErrMessage | undefined) => ZodBigInt;
361 gt(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
362 lte(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
363 max: (value: bigint, message?: errorUtil.ErrMessage | undefined) => ZodBigInt;
364 lt(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
365 protected setLimit(kind: "min" | "max", value: bigint, inclusive: boolean, message?: string): ZodBigInt;
366 _addCheck(check: ZodBigIntCheck): ZodBigInt;
367 positive(message?: errorUtil.ErrMessage): ZodBigInt;
368 negative(message?: errorUtil.ErrMessage): ZodBigInt;
369 nonpositive(message?: errorUtil.ErrMessage): ZodBigInt;
370 nonnegative(message?: errorUtil.ErrMessage): ZodBigInt;
371 multipleOf(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
372 get minValue(): bigint | null;
373 get maxValue(): bigint | null;
374}
375export interface ZodBooleanDef extends ZodTypeDef {
376 typeName: ZodFirstPartyTypeKind.ZodBoolean;
377 coerce: boolean;
378}
379export declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef, boolean> {
380 _parse(input: ParseInput): ParseReturnType<boolean>;
381 static create: (params?: ({
382 errorMap?: ZodErrorMap | undefined;
383 invalid_type_error?: string | undefined;
384 required_error?: string | undefined;
385 message?: string | undefined;
386 description?: string | undefined;
387 } & {
388 coerce?: boolean | undefined;
389 }) | undefined) => ZodBoolean;
390}
391export declare type ZodDateCheck = {
392 kind: "min";
393 value: number;
394 message?: string;
395} | {
396 kind: "max";
397 value: number;
398 message?: string;
399};
400export interface ZodDateDef extends ZodTypeDef {
401 checks: ZodDateCheck[];
402 coerce: boolean;
403 typeName: ZodFirstPartyTypeKind.ZodDate;
404}
405export declare class ZodDate extends ZodType<Date, ZodDateDef, Date> {
406 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
407 _addCheck(check: ZodDateCheck): ZodDate;
408 min(minDate: Date, message?: errorUtil.ErrMessage): ZodDate;
409 max(maxDate: Date, message?: errorUtil.ErrMessage): ZodDate;
410 get minDate(): Date | null;
411 get maxDate(): Date | null;
412 static create: (params?: ({
413 errorMap?: ZodErrorMap | undefined;
414 invalid_type_error?: string | undefined;
415 required_error?: string | undefined;
416 message?: string | undefined;
417 description?: string | undefined;
418 } & {
419 coerce?: boolean | undefined;
420 }) | undefined) => ZodDate;
421}
422export interface ZodSymbolDef extends ZodTypeDef {
423 typeName: ZodFirstPartyTypeKind.ZodSymbol;
424}
425export declare class ZodSymbol extends ZodType<symbol, ZodSymbolDef, symbol> {
426 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
427 static create: (params?: RawCreateParams) => ZodSymbol;
428}
429export interface ZodUndefinedDef extends ZodTypeDef {
430 typeName: ZodFirstPartyTypeKind.ZodUndefined;
431}
432export declare class ZodUndefined extends ZodType<undefined, ZodUndefinedDef, undefined> {
433 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
434 params?: RawCreateParams;
435 static create: (params?: RawCreateParams) => ZodUndefined;
436}
437export interface ZodNullDef extends ZodTypeDef {
438 typeName: ZodFirstPartyTypeKind.ZodNull;
439}
440export declare class ZodNull extends ZodType<null, ZodNullDef, null> {
441 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
442 static create: (params?: RawCreateParams) => ZodNull;
443}
444export interface ZodAnyDef extends ZodTypeDef {
445 typeName: ZodFirstPartyTypeKind.ZodAny;
446}
447export declare class ZodAny extends ZodType<any, ZodAnyDef, any> {
448 _any: true;
449 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
450 static create: (params?: RawCreateParams) => ZodAny;
451}
452export interface ZodUnknownDef extends ZodTypeDef {
453 typeName: ZodFirstPartyTypeKind.ZodUnknown;
454}
455export declare class ZodUnknown extends ZodType<unknown, ZodUnknownDef, unknown> {
456 _unknown: true;
457 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
458 static create: (params?: RawCreateParams) => ZodUnknown;
459}
460export interface ZodNeverDef extends ZodTypeDef {
461 typeName: ZodFirstPartyTypeKind.ZodNever;
462}
463export declare class ZodNever extends ZodType<never, ZodNeverDef, never> {
464 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
465 static create: (params?: RawCreateParams) => ZodNever;
466}
467export interface ZodVoidDef extends ZodTypeDef {
468 typeName: ZodFirstPartyTypeKind.ZodVoid;
469}
470export declare class ZodVoid extends ZodType<void, ZodVoidDef, void> {
471 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
472 static create: (params?: RawCreateParams) => ZodVoid;
473}
474export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
475 type: T;
476 typeName: ZodFirstPartyTypeKind.ZodArray;
477 exactLength: {
478 value: number;
479 message?: string;
480 } | null;
481 minLength: {
482 value: number;
483 message?: string;
484 } | null;
485 maxLength: {
486 value: number;
487 message?: string;
488 } | null;
489}
490export declare type ArrayCardinality = "many" | "atleastone";
491export declare type arrayOutputType<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> = Cardinality extends "atleastone" ? [T["_output"], ...T["_output"][]] : T["_output"][];
492export declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> extends ZodType<arrayOutputType<T, Cardinality>, ZodArrayDef<T>, Cardinality extends "atleastone" ? [T["_input"], ...T["_input"][]] : T["_input"][]> {
493 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
494 get element(): T;
495 min(minLength: number, message?: errorUtil.ErrMessage): this;
496 max(maxLength: number, message?: errorUtil.ErrMessage): this;
497 length(len: number, message?: errorUtil.ErrMessage): this;
498 nonempty(message?: errorUtil.ErrMessage): ZodArray<T, "atleastone">;
499 static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodArray<T_1, "many">;
500}
501export declare type ZodNonEmptyArray<T extends ZodTypeAny> = ZodArray<T, "atleastone">;
502export declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
503export interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
504 typeName: ZodFirstPartyTypeKind.ZodObject;
505 shape: () => T;
506 catchall: Catchall;
507 unknownKeys: UnknownKeys;
508}
509export declare type mergeTypes<A, B> = {
510 [k in keyof A | keyof B]: k extends keyof B ? B[k] : k extends keyof A ? A[k] : never;
511};
512export declare type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<objectUtil.addQuestionMarks<baseObjectOutputType<Shape>>> & CatchallOutput<Catchall> & PassthroughType<UnknownKeys>;
513export declare type baseObjectOutputType<Shape extends ZodRawShape> = {
514 [k in keyof Shape]: Shape[k]["_output"];
515};
516export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<baseObjectInputType<Shape>> & CatchallInput<Catchall> & PassthroughType<UnknownKeys>;
517export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.addQuestionMarks<{
518 [k in keyof Shape]: Shape[k]["_input"];
519}>;
520export declare type CatchallOutput<T extends ZodType> = ZodType extends T ? unknown : {
521 [k: string]: T["_output"];
522};
523export declare type CatchallInput<T extends ZodType> = ZodType extends T ? unknown : {
524 [k: string]: T["_input"];
525};
526export declare type PassthroughType<T extends UnknownKeysParam> = T extends "passthrough" ? {
527 [k: string]: unknown;
528} : unknown;
529export declare type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T extends ZodNullable<infer U> ? ZodNullable<deoptional<U>> : T;
530export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny>;
531export declare type noUnrecognized<Obj extends object, Shape extends object> = {
532 [k in keyof Obj]: k extends keyof Shape ? Obj[k] : never;
533};
534export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
535 private _cached;
536 _getCached(): {
537 shape: T;
538 keys: string[];
539 };
540 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
541 get shape(): T;
542 strict(message?: errorUtil.ErrMessage): ZodObject<T, "strict", Catchall>;
543 strip(): ZodObject<T, "strip", Catchall>;
544 passthrough(): ZodObject<T, "passthrough", Catchall>;
545 /**
546 * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
547 * If you want to pass through unknown properties, use `.passthrough()` instead.
548 */
549 nonstrict: () => ZodObject<T, "passthrough", Catchall>;
550 extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
551 /**
552 * @deprecated Use `.extend` instead
553 * */
554 augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall, objectOutputType<objectUtil.extendShape<T, Augmentation>, Catchall, UnknownKeys>, objectInputType<objectUtil.extendShape<T, Augmentation>, Catchall, UnknownKeys>>;
555 /**
556 * Prior to zod@1.0.12 there was a bug in the
557 * inferred type of merged objects. Please
558 * upgrade if you are experiencing issues.
559 */
560 merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
561 setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & {
562 [k in Key]: Schema;
563 }, UnknownKeys, Catchall>;
564 catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
565 pick<Mask extends util.Exactly<{
566 [k in keyof T]?: true;
567 }, Mask>>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
568 omit<Mask extends util.Exactly<{
569 [k in keyof T]?: true;
570 }, Mask>>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
571 /**
572 * @deprecated
573 */
574 deepPartial(): partialUtil.DeepPartial<this>;
575 partial(): ZodObject<{
576 [k in keyof T]: ZodOptional<T[k]>;
577 }, UnknownKeys, Catchall>;
578 partial<Mask extends util.Exactly<{
579 [k in keyof T]?: true;
580 }, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<{
581 [k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k];
582 }>, UnknownKeys, Catchall>;
583 required(): ZodObject<{
584 [k in keyof T]: deoptional<T[k]>;
585 }, UnknownKeys, Catchall>;
586 required<Mask extends util.Exactly<{
587 [k in keyof T]?: true;
588 }, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<{
589 [k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
590 }>, UnknownKeys, Catchall>;
591 keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
592 static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_1]; }>;
593 static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_1]; }>;
594 static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_1]; }>;
595}
596export declare type AnyZodObject = ZodObject<any, any, any>;
597export declare type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
598export interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[
599 ZodTypeAny,
600 ZodTypeAny,
601 ...ZodTypeAny[]
602]>> extends ZodTypeDef {
603 options: T;
604 typeName: ZodFirstPartyTypeKind.ZodUnion;
605}
606export declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
607 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
608 get options(): T;
609 static create: <T_1 extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T_1, params?: RawCreateParams) => ZodUnion<T_1>;
610}
611export declare type ZodDiscriminatedUnionOption<Discriminator extends string> = ZodObject<{
612 [key in Discriminator]: ZodTypeAny;
613} & ZodRawShape, UnknownKeysParam, ZodTypeAny>;
614export interface ZodDiscriminatedUnionDef<Discriminator extends string, Options extends ZodDiscriminatedUnionOption<string>[] = ZodDiscriminatedUnionOption<string>[]> extends ZodTypeDef {
615 discriminator: Discriminator;
616 options: Options;
617 optionsMap: Map<Primitive, ZodDiscriminatedUnionOption<any>>;
618 typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion;
619}
620export declare class ZodDiscriminatedUnion<Discriminator extends string, Options extends ZodDiscriminatedUnionOption<Discriminator>[]> extends ZodType<output<Options[number]>, ZodDiscriminatedUnionDef<Discriminator, Options>, input<Options[number]>> {
621 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
622 get discriminator(): Discriminator;
623 get options(): Options;
624 get optionsMap(): Map<Primitive, ZodDiscriminatedUnionOption<any>>;
625 /**
626 * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
627 * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
628 * have a different value for each object in the union.
629 * @param discriminator the name of the discriminator property
630 * @param types an array of object schemas
631 * @param params
632 */
633 static create<Discriminator extends string, Types extends [
634 ZodDiscriminatedUnionOption<Discriminator>,
635 ...ZodDiscriminatedUnionOption<Discriminator>[]
636 ]>(discriminator: Discriminator, options: Types, params?: RawCreateParams): ZodDiscriminatedUnion<Discriminator, Types>;
637}
638export interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
639 left: T;
640 right: U;
641 typeName: ZodFirstPartyTypeKind.ZodIntersection;
642}
643export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
644 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
645 static create: <T_1 extends ZodTypeAny, U_1 extends ZodTypeAny>(left: T_1, right: U_1, params?: RawCreateParams) => ZodIntersection<T_1, U_1>;
646}
647export declare type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
648export declare type AssertArray<T> = T extends any[] ? T : never;
649export declare type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
650 [k in keyof T]: T[k] extends ZodType<any, any, any> ? T[k]["_output"] : never;
651}>;
652export declare type OutputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...OutputTypeOfTuple<T>, ...Rest["_output"][]] : OutputTypeOfTuple<T>;
653export declare type InputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
654 [k in keyof T]: T[k] extends ZodType<any, any, any> ? T[k]["_input"] : never;
655}>;
656export declare type InputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...InputTypeOfTuple<T>, ...Rest["_input"][]] : InputTypeOfTuple<T>;
657export interface ZodTupleDef<T extends ZodTupleItems | [] = ZodTupleItems, Rest extends ZodTypeAny | null = null> extends ZodTypeDef {
658 items: T;
659 rest: Rest;
660 typeName: ZodFirstPartyTypeKind.ZodTuple;
661}
662export declare type AnyZodTuple = ZodTuple<[
663 ZodTypeAny,
664 ...ZodTypeAny[]
665] | [], ZodTypeAny | null>;
666export declare class ZodTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]], Rest extends ZodTypeAny | null = null> extends ZodType<OutputTypeOfTupleWithRest<T, Rest>, ZodTupleDef<T, Rest>, InputTypeOfTupleWithRest<T, Rest>> {
667 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
668 get items(): T;
669 rest<Rest extends ZodTypeAny>(rest: Rest): ZodTuple<T, Rest>;
670 static create: <T_1 extends [] | [ZodTypeAny, ...ZodTypeAny[]]>(schemas: T_1, params?: RawCreateParams) => ZodTuple<T_1, null>;
671}
672export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
673 valueType: Value;
674 keyType: Key;
675 typeName: ZodFirstPartyTypeKind.ZodRecord;
676}
677export declare type KeySchema = ZodType<string | number | symbol, any, any>;
678export declare type RecordType<K extends string | number | symbol, V> = [
679 string
680] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : [BRAND<string | number | symbol>] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
681export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<RecordType<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, RecordType<Key["_input"], Value["_input"]>> {
682 get keySchema(): Key;
683 get valueSchema(): Value;
684 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
685 get element(): Value;
686 static create<Value extends ZodTypeAny>(valueType: Value, params?: RawCreateParams): ZodRecord<ZodString, Value>;
687 static create<Keys extends KeySchema, Value extends ZodTypeAny>(keySchema: Keys, valueType: Value, params?: RawCreateParams): ZodRecord<Keys, Value>;
688}
689export interface ZodMapDef<Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
690 valueType: Value;
691 keyType: Key;
692 typeName: ZodFirstPartyTypeKind.ZodMap;
693}
694export declare class ZodMap<Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Map<Key["_output"], Value["_output"]>, ZodMapDef<Key, Value>, Map<Key["_input"], Value["_input"]>> {
695 get keySchema(): Key;
696 get valueSchema(): Value;
697 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
698 static create: <Key_1 extends ZodTypeAny = ZodTypeAny, Value_1 extends ZodTypeAny = ZodTypeAny>(keyType: Key_1, valueType: Value_1, params?: RawCreateParams) => ZodMap<Key_1, Value_1>;
699}
700export interface ZodSetDef<Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
701 valueType: Value;
702 typeName: ZodFirstPartyTypeKind.ZodSet;
703 minSize: {
704 value: number;
705 message?: string;
706 } | null;
707 maxSize: {
708 value: number;
709 message?: string;
710 } | null;
711}
712export declare class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Set<Value["_output"]>, ZodSetDef<Value>, Set<Value["_input"]>> {
713 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
714 min(minSize: number, message?: errorUtil.ErrMessage): this;
715 max(maxSize: number, message?: errorUtil.ErrMessage): this;
716 size(size: number, message?: errorUtil.ErrMessage): this;
717 nonempty(message?: errorUtil.ErrMessage): ZodSet<Value>;
718 static create: <Value_1 extends ZodTypeAny = ZodTypeAny>(valueType: Value_1, params?: RawCreateParams) => ZodSet<Value_1>;
719}
720export interface ZodFunctionDef<Args extends ZodTuple<any, any> = ZodTuple<any, any>, Returns extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
721 args: Args;
722 returns: Returns;
723 typeName: ZodFirstPartyTypeKind.ZodFunction;
724}
725export declare type OuterTypeOfFunction<Args extends ZodTuple<any, any>, Returns extends ZodTypeAny> = Args["_input"] extends Array<any> ? (...args: Args["_input"]) => Returns["_output"] : never;
726export declare type InnerTypeOfFunction<Args extends ZodTuple<any, any>, Returns extends ZodTypeAny> = Args["_output"] extends Array<any> ? (...args: Args["_output"]) => Returns["_input"] : never;
727export declare class ZodFunction<Args extends ZodTuple<any, any>, Returns extends ZodTypeAny> extends ZodType<OuterTypeOfFunction<Args, Returns>, ZodFunctionDef<Args, Returns>, InnerTypeOfFunction<Args, Returns>> {
728 _parse(input: ParseInput): ParseReturnType<any>;
729 parameters(): Args;
730 returnType(): Returns;
731 args<Items extends Parameters<(typeof ZodTuple)["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
732 returns<NewReturnType extends ZodType<any, any, any>>(returnType: NewReturnType): ZodFunction<Args, NewReturnType>;
733 implement<F extends InnerTypeOfFunction<Args, Returns>>(func: F): ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
734 strictImplement(func: InnerTypeOfFunction<Args, Returns>): InnerTypeOfFunction<Args, Returns>;
735 validate: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
736 static create(): ZodFunction<ZodTuple<[], ZodUnknown>, ZodUnknown>;
737 static create<T extends AnyZodTuple = ZodTuple<[], ZodUnknown>>(args: T): ZodFunction<T, ZodUnknown>;
738 static create<T extends AnyZodTuple, U extends ZodTypeAny>(args: T, returns: U): ZodFunction<T, U>;
739 static create<T extends AnyZodTuple = ZodTuple<[], ZodUnknown>, U extends ZodTypeAny = ZodUnknown>(args: T, returns: U, params?: RawCreateParams): ZodFunction<T, U>;
740}
741export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
742 getter: () => T;
743 typeName: ZodFirstPartyTypeKind.ZodLazy;
744}
745export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, ZodLazyDef<T>, input<T>> {
746 get schema(): T;
747 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
748 static create: <T_1 extends ZodTypeAny>(getter: () => T_1, params?: RawCreateParams) => ZodLazy<T_1>;
749}
750export interface ZodLiteralDef<T = any> extends ZodTypeDef {
751 value: T;
752 typeName: ZodFirstPartyTypeKind.ZodLiteral;
753}
754export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>, T> {
755 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
756 get value(): T;
757 static create: <T_1 extends Primitive>(value: T_1, params?: RawCreateParams) => ZodLiteral<T_1>;
758}
759export declare type ArrayKeys = keyof any[];
760export declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
761export declare type EnumValues<T extends string = string> = readonly [T, ...T[]];
762export declare type Values<T extends EnumValues> = {
763 [k in T[number]]: k;
764};
765export interface ZodEnumDef<T extends EnumValues = EnumValues> extends ZodTypeDef {
766 values: T;
767 typeName: ZodFirstPartyTypeKind.ZodEnum;
768}
769export declare type Writeable<T> = {
770 -readonly [P in keyof T]: T[P];
771};
772export declare type FilterEnum<Values, ToExclude> = Values extends [] ? [] : Values extends [infer Head, ...infer Rest] ? Head extends ToExclude ? FilterEnum<Rest, ToExclude> : [Head, ...FilterEnum<Rest, ToExclude>] : never;
773export declare type typecast<A, T> = A extends T ? A : never;
774declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T, params?: RawCreateParams): ZodEnum<Writeable<T>>;
775declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T, params?: RawCreateParams): ZodEnum<T>;
776export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>, T[number]> {
777 #private;
778 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
779 get options(): T;
780 get enum(): Values<T>;
781 get Values(): Values<T>;
782 get Enum(): Values<T>;
783 extract<ToExtract extends readonly [T[number], ...T[number][]]>(values: ToExtract, newDef?: RawCreateParams): ZodEnum<Writeable<ToExtract>>;
784 exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude, newDef?: RawCreateParams): ZodEnum<typecast<Writeable<FilterEnum<T, ToExclude[number]>>, [string, ...string[]]>>;
785 static create: typeof createZodEnum;
786}
787export interface ZodNativeEnumDef<T extends EnumLike = EnumLike> extends ZodTypeDef {
788 values: T;
789 typeName: ZodFirstPartyTypeKind.ZodNativeEnum;
790}
791export declare type EnumLike = {
792 [k: string]: string | number;
793 [nu: number]: string;
794};
795export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T], ZodNativeEnumDef<T>, T[keyof T]> {
796 #private;
797 _parse(input: ParseInput): ParseReturnType<T[keyof T]>;
798 get enum(): T;
799 static create: <T_1 extends EnumLike>(values: T_1, params?: RawCreateParams) => ZodNativeEnum<T_1>;
800}
801export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
802 type: T;
803 typeName: ZodFirstPartyTypeKind.ZodPromise;
804}
805export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
806 unwrap(): T;
807 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
808 static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodPromise<T_1>;
809}
810export declare type Refinement<T> = (arg: T, ctx: RefinementCtx) => any;
811export declare type SuperRefinement<T> = (arg: T, ctx: RefinementCtx) => void | Promise<void>;
812export declare type RefinementEffect<T> = {
813 type: "refinement";
814 refinement: (arg: T, ctx: RefinementCtx) => any;
815};
816export declare type TransformEffect<T> = {
817 type: "transform";
818 transform: (arg: T, ctx: RefinementCtx) => any;
819};
820export declare type PreprocessEffect<T> = {
821 type: "preprocess";
822 transform: (arg: T, ctx: RefinementCtx) => any;
823};
824export declare type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEffect<T>;
825export interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
826 schema: T;
827 typeName: ZodFirstPartyTypeKind.ZodEffects;
828 effect: Effect<any>;
829}
830export declare class ZodEffects<T extends ZodTypeAny, Output = output<T>, Input = input<T>> extends ZodType<Output, ZodEffectsDef<T>, Input> {
831 innerType(): T;
832 sourceType(): T;
833 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
834 static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], input<I>>;
835 static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
836}
837export { ZodEffects as ZodTransformer };
838export interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
839 innerType: T;
840 typeName: ZodFirstPartyTypeKind.ZodOptional;
841}
842export declare type ZodOptionalType<T extends ZodTypeAny> = ZodOptional<T>;
843export declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
844 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
845 unwrap(): T;
846 static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodOptional<T_1>;
847}
848export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
849 innerType: T;
850 typeName: ZodFirstPartyTypeKind.ZodNullable;
851}
852export declare type ZodNullableType<T extends ZodTypeAny> = ZodNullable<T>;
853export declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
854 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
855 unwrap(): T;
856 static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodNullable<T_1>;
857}
858export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
859 innerType: T;
860 defaultValue: () => util.noUndefined<T["_input"]>;
861 typeName: ZodFirstPartyTypeKind.ZodDefault;
862}
863export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodDefaultDef<T>, T["_input"] | undefined> {
864 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
865 removeDefault(): T;
866 static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
867 errorMap?: ZodErrorMap | undefined;
868 invalid_type_error?: string | undefined;
869 required_error?: string | undefined;
870 message?: string | undefined;
871 description?: string | undefined;
872 } & {
873 default: T_1["_input"] | (() => util.noUndefined<T_1["_input"]>);
874 }) => ZodDefault<T_1>;
875}
876export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
877 innerType: T;
878 catchValue: (ctx: {
879 error: ZodError;
880 input: unknown;
881 }) => T["_input"];
882 typeName: ZodFirstPartyTypeKind.ZodCatch;
883}
884export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
885 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
886 removeCatch(): T;
887 static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
888 errorMap?: ZodErrorMap | undefined;
889 invalid_type_error?: string | undefined;
890 required_error?: string | undefined;
891 message?: string | undefined;
892 description?: string | undefined;
893 } & {
894 catch: T_1["_output"] | (() => T_1["_output"]);
895 }) => ZodCatch<T_1>;
896}
897export interface ZodNaNDef extends ZodTypeDef {
898 typeName: ZodFirstPartyTypeKind.ZodNaN;
899}
900export declare class ZodNaN extends ZodType<number, ZodNaNDef, number> {
901 _parse(input: ParseInput): ParseReturnType<any>;
902 static create: (params?: RawCreateParams) => ZodNaN;
903}
904export interface ZodBrandedDef<T extends ZodTypeAny> extends ZodTypeDef {
905 type: T;
906 typeName: ZodFirstPartyTypeKind.ZodBranded;
907}
908export declare const BRAND: unique symbol;
909export declare type BRAND<T extends string | number | symbol> = {
910 [BRAND]: {
911 [k in T]: true;
912 };
913};
914export declare class ZodBranded<T extends ZodTypeAny, B extends string | number | symbol> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
915 _parse(input: ParseInput): ParseReturnType<any>;
916 unwrap(): T;
917}
918export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodTypeDef {
919 in: A;
920 out: B;
921 typeName: ZodFirstPartyTypeKind.ZodPipeline;
922}
923export declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
924 _parse(input: ParseInput): ParseReturnType<any>;
925 static create<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodPipeline<A, B>;
926}
927declare type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
928 readonly [Symbol.toStringTag]: string;
929} | Date | Error | Generator | Promise<unknown> | RegExp;
930declare type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
931export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
932 innerType: T;
933 typeName: ZodFirstPartyTypeKind.ZodReadonly;
934}
935export declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, MakeReadonly<T["_input"]>> {
936 _parse(input: ParseInput): ParseReturnType<this["_output"]>;
937 static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodReadonly<T_1>;
938 unwrap(): T;
939}
940declare type CustomParams = CustomErrorParams & {
941 fatal?: boolean;
942};
943export declare function custom<T>(check?: (data: any) => any, params?: string | CustomParams | ((input: any) => CustomParams),
944/**
945 * @deprecated
946 *
947 * Pass `fatal` into the params object instead:
948 *
949 * ```ts
950 * z.string().custom((val) => val.length > 5, { fatal: false })
951 * ```
952 *
953 */
954fatal?: boolean): ZodType<T, ZodTypeDef, T>;
955export { ZodType as Schema, ZodType as ZodSchema };
956export declare const late: {
957 object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_1]; }>;
958};
959export declare enum ZodFirstPartyTypeKind {
960 ZodString = "ZodString",
961 ZodNumber = "ZodNumber",
962 ZodNaN = "ZodNaN",
963 ZodBigInt = "ZodBigInt",
964 ZodBoolean = "ZodBoolean",
965 ZodDate = "ZodDate",
966 ZodSymbol = "ZodSymbol",
967 ZodUndefined = "ZodUndefined",
968 ZodNull = "ZodNull",
969 ZodAny = "ZodAny",
970 ZodUnknown = "ZodUnknown",
971 ZodNever = "ZodNever",
972 ZodVoid = "ZodVoid",
973 ZodArray = "ZodArray",
974 ZodObject = "ZodObject",
975 ZodUnion = "ZodUnion",
976 ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
977 ZodIntersection = "ZodIntersection",
978 ZodTuple = "ZodTuple",
979 ZodRecord = "ZodRecord",
980 ZodMap = "ZodMap",
981 ZodSet = "ZodSet",
982 ZodFunction = "ZodFunction",
983 ZodLazy = "ZodLazy",
984 ZodLiteral = "ZodLiteral",
985 ZodEnum = "ZodEnum",
986 ZodEffects = "ZodEffects",
987 ZodNativeEnum = "ZodNativeEnum",
988 ZodOptional = "ZodOptional",
989 ZodNullable = "ZodNullable",
990 ZodDefault = "ZodDefault",
991 ZodCatch = "ZodCatch",
992 ZodPromise = "ZodPromise",
993 ZodBranded = "ZodBranded",
994 ZodPipeline = "ZodPipeline",
995 ZodReadonly = "ZodReadonly"
996}
997export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<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> | ZodCatch<any> | ZodPromise<any> | ZodBranded<any, any> | ZodPipeline<any, any> | ZodReadonly<any> | ZodSymbol;
998declare abstract class Class {
999 constructor(..._: any[]);
1000}
1001declare const instanceOfType: <T extends typeof Class>(cls: T, params?: CustomParams) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
1002declare const stringType: (params?: ({
1003 errorMap?: ZodErrorMap | undefined;
1004 invalid_type_error?: string | undefined;
1005 required_error?: string | undefined;
1006 message?: string | undefined;
1007 description?: string | undefined;
1008} & {
1009 coerce?: true | undefined;
1010}) | undefined) => ZodString;
1011declare const numberType: (params?: ({
1012 errorMap?: ZodErrorMap | undefined;
1013 invalid_type_error?: string | undefined;
1014 required_error?: string | undefined;
1015 message?: string | undefined;
1016 description?: string | undefined;
1017} & {
1018 coerce?: boolean | undefined;
1019}) | undefined) => ZodNumber;
1020declare const nanType: (params?: RawCreateParams) => ZodNaN;
1021declare const bigIntType: (params?: ({
1022 errorMap?: ZodErrorMap | undefined;
1023 invalid_type_error?: string | undefined;
1024 required_error?: string | undefined;
1025 message?: string | undefined;
1026 description?: string | undefined;
1027} & {
1028 coerce?: boolean | undefined;
1029}) | undefined) => ZodBigInt;
1030declare const booleanType: (params?: ({
1031 errorMap?: ZodErrorMap | undefined;
1032 invalid_type_error?: string | undefined;
1033 required_error?: string | undefined;
1034 message?: string | undefined;
1035 description?: string | undefined;
1036} & {
1037 coerce?: boolean | undefined;
1038}) | undefined) => ZodBoolean;
1039declare const dateType: (params?: ({
1040 errorMap?: ZodErrorMap | undefined;
1041 invalid_type_error?: string | undefined;
1042 required_error?: string | undefined;
1043 message?: string | undefined;
1044 description?: string | undefined;
1045} & {
1046 coerce?: boolean | undefined;
1047}) | undefined) => ZodDate;
1048declare const symbolType: (params?: RawCreateParams) => ZodSymbol;
1049declare const undefinedType: (params?: RawCreateParams) => ZodUndefined;
1050declare const nullType: (params?: RawCreateParams) => ZodNull;
1051declare const anyType: (params?: RawCreateParams) => ZodAny;
1052declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
1053declare const neverType: (params?: RawCreateParams) => ZodNever;
1054declare const voidType: (params?: RawCreateParams) => ZodVoid;
1055declare const arrayType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodArray<T, "many">;
1056declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_1]; }>;
1057declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_1]; }>;
1058declare const unionType: <T extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T, params?: RawCreateParams) => ZodUnion<T>;
1059declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
1060declare const intersectionType: <T extends ZodTypeAny, U extends ZodTypeAny>(left: T, right: U, params?: RawCreateParams) => ZodIntersection<T, U>;
1061declare const tupleType: <T extends [] | [ZodTypeAny, ...ZodTypeAny[]]>(schemas: T, params?: RawCreateParams) => ZodTuple<T, null>;
1062declare const recordType: typeof ZodRecord.create;
1063declare const mapType: <Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny>(keyType: Key, valueType: Value, params?: RawCreateParams) => ZodMap<Key, Value>;
1064declare const setType: <Value extends ZodTypeAny = ZodTypeAny>(valueType: Value, params?: RawCreateParams) => ZodSet<Value>;
1065declare const functionType: typeof ZodFunction.create;
1066declare const lazyType: <T extends ZodTypeAny>(getter: () => T, params?: RawCreateParams) => ZodLazy<T>;
1067declare const literalType: <T extends Primitive>(value: T, params?: RawCreateParams) => ZodLiteral<T>;
1068declare const enumType: typeof createZodEnum;
1069declare const nativeEnumType: <T extends EnumLike>(values: T, params?: RawCreateParams) => ZodNativeEnum<T>;
1070declare const promiseType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodPromise<T>;
1071declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], input<I>>;
1072declare const optionalType: <T extends ZodTypeAny>(type: T, params?: RawCreateParams) => ZodOptional<T>;
1073declare const nullableType: <T extends ZodTypeAny>(type: T, params?: RawCreateParams) => ZodNullable<T>;
1074declare const preprocessType: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
1075declare const pipelineType: typeof ZodPipeline.create;
1076declare const ostring: () => ZodOptional<ZodString>;
1077declare const onumber: () => ZodOptional<ZodNumber>;
1078declare const oboolean: () => ZodOptional<ZodBoolean>;
1079export declare const coerce: {
1080 string: (params?: ({
1081 errorMap?: ZodErrorMap | undefined;
1082 invalid_type_error?: string | undefined;
1083 required_error?: string | undefined;
1084 message?: string | undefined;
1085 description?: string | undefined;
1086 } & {
1087 coerce?: true | undefined;
1088 }) | undefined) => ZodString;
1089 number: (params?: ({
1090 errorMap?: ZodErrorMap | undefined;
1091 invalid_type_error?: string | undefined;
1092 required_error?: string | undefined;
1093 message?: string | undefined;
1094 description?: string | undefined;
1095 } & {
1096 coerce?: boolean | undefined;
1097 }) | undefined) => ZodNumber;
1098 boolean: (params?: ({
1099 errorMap?: ZodErrorMap | undefined;
1100 invalid_type_error?: string | undefined;
1101 required_error?: string | undefined;
1102 message?: string | undefined;
1103 description?: string | undefined;
1104 } & {
1105 coerce?: boolean | undefined;
1106 }) | undefined) => ZodBoolean;
1107 bigint: (params?: ({
1108 errorMap?: ZodErrorMap | undefined;
1109 invalid_type_error?: string | undefined;
1110 required_error?: string | undefined;
1111 message?: string | undefined;
1112 description?: string | undefined;
1113 } & {
1114 coerce?: boolean | undefined;
1115 }) | undefined) => ZodBigInt;
1116 date: (params?: ({
1117 errorMap?: ZodErrorMap | undefined;
1118 invalid_type_error?: string | undefined;
1119 required_error?: string | undefined;
1120 message?: string | undefined;
1121 description?: string | undefined;
1122 } & {
1123 coerce?: boolean | undefined;
1124 }) | undefined) => ZodDate;
1125};
1126export { anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, dateType as date, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, instanceOfType as instanceof, intersectionType as intersection, lazyType as lazy, literalType as literal, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, recordType as record, setType as set, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, };
1127export declare const NEVER: never;