schemas.d.cts 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. import * as core from "../core/index.cjs";
  2. import { util } from "../core/index.cjs";
  3. import type { StandardSchemaWithJSONProps } from "../core/standard-schema.cjs";
  4. import * as parse from "./parse.cjs";
  5. export type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;
  6. export interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
  7. def: Internals["def"];
  8. type: Internals["def"]["type"];
  9. /** @deprecated Use `.def` instead. */
  10. _def: Internals["def"];
  11. /** @deprecated Use `z.output<typeof schema>` instead. */
  12. _output: Internals["output"];
  13. /** @deprecated Use `z.input<typeof schema>` instead. */
  14. _input: Internals["input"];
  15. "~standard": ZodStandardSchemaWithJSON<this>;
  16. /** Converts this schema to a JSON Schema representation. */
  17. toJSONSchema(params?: core.ToJSONSchemaParams): core.ZodStandardJSONSchemaPayload<this>;
  18. check(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
  19. with(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
  20. clone(def?: Internals["def"], params?: {
  21. parent: boolean;
  22. }): this;
  23. register<R extends core.$ZodRegistry>(registry: R, ...meta: this extends R["_schema"] ? undefined extends R["_meta"] ? [core.$replace<R["_meta"], this>?] : [core.$replace<R["_meta"], this>] : ["Incompatible schema"]): this;
  24. brand<T extends PropertyKey = PropertyKey, Dir extends "in" | "out" | "inout" = "out">(value?: T): PropertyKey extends T ? this : core.$ZodBranded<this, T, Dir>;
  25. parse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
  26. safeParse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
  27. parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
  28. safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
  29. spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
  30. encode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): core.input<this>;
  31. decode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
  32. encodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.input<this>>;
  33. decodeAsync(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
  34. safeEncode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.input<this>>;
  35. safeDecode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
  36. safeEncodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.input<this>>>;
  37. safeDecodeAsync(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
  38. refine<Ch extends (arg: core.output<this>) => unknown | Promise<unknown>>(check: Ch, params?: string | core.$ZodCustomParams): Ch extends (arg: any) => arg is infer R ? this & ZodType<R, core.input<this>> : this;
  39. superRefine(refinement: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => void | Promise<void>): this;
  40. overwrite(fn: (x: core.output<this>) => core.output<this>): this;
  41. optional(): ZodOptional<this>;
  42. exactOptional(): ZodExactOptional<this>;
  43. nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
  44. nullable(): ZodNullable<this>;
  45. nullish(): ZodOptional<ZodNullable<this>>;
  46. default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
  47. default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
  48. prefault(def: () => core.input<this>): ZodPrefault<this>;
  49. prefault(def: core.input<this>): ZodPrefault<this>;
  50. array(): ZodArray<this>;
  51. or<T extends core.SomeType>(option: T): ZodUnion<[this, T]>;
  52. and<T extends core.SomeType>(incoming: T): ZodIntersection<this, T>;
  53. transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
  54. catch(def: core.output<this>): ZodCatch<this>;
  55. catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
  56. pipe<T extends core.$ZodType<any, core.output<this>>>(target: T | core.$ZodType<any, core.output<this>>): ZodPipe<this, T>;
  57. readonly(): ZodReadonly<this>;
  58. /** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
  59. describe(description: string): this;
  60. description?: string;
  61. /** Returns the metadata associated with this instance in `z.globalRegistry` */
  62. meta(): core.$replace<core.GlobalMeta, this> | undefined;
  63. /** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
  64. meta(data: core.$replace<core.GlobalMeta, this>): this;
  65. /** @deprecated Try safe-parsing `undefined` (this is what `isOptional` does internally):
  66. *
  67. * ```ts
  68. * const schema = z.string().optional();
  69. * const isOptional = schema.safeParse(undefined).success; // true
  70. * ```
  71. */
  72. isOptional(): boolean;
  73. /**
  74. * @deprecated Try safe-parsing `null` (this is what `isNullable` does internally):
  75. *
  76. * ```ts
  77. * const schema = z.string().nullable();
  78. * const isNullable = schema.safeParse(null).success; // true
  79. * ```
  80. */
  81. isNullable(): boolean;
  82. apply<T>(fn: (schema: this) => T): T;
  83. }
  84. export interface _ZodType<out Internals extends core.$ZodTypeInternals = core.$ZodTypeInternals> extends ZodType<any, any, Internals> {
  85. }
  86. export declare const ZodType: core.$constructor<ZodType>;
  87. export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>> extends _ZodType<T> {
  88. format: string | null;
  89. minLength: number | null;
  90. maxLength: number | null;
  91. regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
  92. includes(value: string, params?: string | core.$ZodCheckIncludesParams): this;
  93. startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
  94. endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
  95. min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
  96. max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
  97. length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
  98. nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
  99. lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
  100. uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
  101. trim(): this;
  102. normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
  103. toLowerCase(): this;
  104. toUpperCase(): this;
  105. slugify(): this;
  106. }
  107. /** @internal */
  108. export declare const _ZodString: core.$constructor<_ZodString>;
  109. export interface ZodString extends _ZodString<core.$ZodStringInternals<string>> {
  110. /** @deprecated Use `z.email()` instead. */
  111. email(params?: string | core.$ZodCheckEmailParams): this;
  112. /** @deprecated Use `z.url()` instead. */
  113. url(params?: string | core.$ZodCheckURLParams): this;
  114. /** @deprecated Use `z.jwt()` instead. */
  115. jwt(params?: string | core.$ZodCheckJWTParams): this;
  116. /** @deprecated Use `z.emoji()` instead. */
  117. emoji(params?: string | core.$ZodCheckEmojiParams): this;
  118. /** @deprecated Use `z.guid()` instead. */
  119. guid(params?: string | core.$ZodCheckGUIDParams): this;
  120. /** @deprecated Use `z.uuid()` instead. */
  121. uuid(params?: string | core.$ZodCheckUUIDParams): this;
  122. /** @deprecated Use `z.uuid()` instead. */
  123. uuidv4(params?: string | core.$ZodCheckUUIDParams): this;
  124. /** @deprecated Use `z.uuid()` instead. */
  125. uuidv6(params?: string | core.$ZodCheckUUIDParams): this;
  126. /** @deprecated Use `z.uuid()` instead. */
  127. uuidv7(params?: string | core.$ZodCheckUUIDParams): this;
  128. /** @deprecated Use `z.nanoid()` instead. */
  129. nanoid(params?: string | core.$ZodCheckNanoIDParams): this;
  130. /** @deprecated Use `z.guid()` instead. */
  131. guid(params?: string | core.$ZodCheckGUIDParams): this;
  132. /** @deprecated Use `z.cuid()` instead. */
  133. cuid(params?: string | core.$ZodCheckCUIDParams): this;
  134. /** @deprecated Use `z.cuid2()` instead. */
  135. cuid2(params?: string | core.$ZodCheckCUID2Params): this;
  136. /** @deprecated Use `z.ulid()` instead. */
  137. ulid(params?: string | core.$ZodCheckULIDParams): this;
  138. /** @deprecated Use `z.base64()` instead. */
  139. base64(params?: string | core.$ZodCheckBase64Params): this;
  140. /** @deprecated Use `z.base64url()` instead. */
  141. base64url(params?: string | core.$ZodCheckBase64URLParams): this;
  142. /** @deprecated Use `z.xid()` instead. */
  143. xid(params?: string | core.$ZodCheckXIDParams): this;
  144. /** @deprecated Use `z.ksuid()` instead. */
  145. ksuid(params?: string | core.$ZodCheckKSUIDParams): this;
  146. /** @deprecated Use `z.ipv4()` instead. */
  147. ipv4(params?: string | core.$ZodCheckIPv4Params): this;
  148. /** @deprecated Use `z.ipv6()` instead. */
  149. ipv6(params?: string | core.$ZodCheckIPv6Params): this;
  150. /** @deprecated Use `z.cidrv4()` instead. */
  151. cidrv4(params?: string | core.$ZodCheckCIDRv4Params): this;
  152. /** @deprecated Use `z.cidrv6()` instead. */
  153. cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
  154. /** @deprecated Use `z.e164()` instead. */
  155. e164(params?: string | core.$ZodCheckE164Params): this;
  156. /** @deprecated Use `z.iso.datetime()` instead. */
  157. datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
  158. /** @deprecated Use `z.iso.date()` instead. */
  159. date(params?: string | core.$ZodCheckISODateParams): this;
  160. /** @deprecated Use `z.iso.time()` instead. */
  161. time(params?: string | core.$ZodCheckISOTimeParams): this;
  162. /** @deprecated Use `z.iso.duration()` instead. */
  163. duration(params?: string | core.$ZodCheckISODurationParams): this;
  164. }
  165. export declare const ZodString: core.$constructor<ZodString>;
  166. export declare function string(params?: string | core.$ZodStringParams): ZodString;
  167. export declare function string<T extends string>(params?: string | core.$ZodStringParams): core.$ZodType<T, T>;
  168. export interface ZodStringFormat<Format extends string = string> extends _ZodString<core.$ZodStringFormatInternals<Format>> {
  169. }
  170. export declare const ZodStringFormat: core.$constructor<ZodStringFormat>;
  171. export interface ZodEmail extends ZodStringFormat<"email"> {
  172. _zod: core.$ZodEmailInternals;
  173. }
  174. export declare const ZodEmail: core.$constructor<ZodEmail>;
  175. export declare function email(params?: string | core.$ZodEmailParams): ZodEmail;
  176. export interface ZodGUID extends ZodStringFormat<"guid"> {
  177. _zod: core.$ZodGUIDInternals;
  178. }
  179. export declare const ZodGUID: core.$constructor<ZodGUID>;
  180. export declare function guid(params?: string | core.$ZodGUIDParams): ZodGUID;
  181. export interface ZodUUID extends ZodStringFormat<"uuid"> {
  182. _zod: core.$ZodUUIDInternals;
  183. }
  184. export declare const ZodUUID: core.$constructor<ZodUUID>;
  185. export declare function uuid(params?: string | core.$ZodUUIDParams): ZodUUID;
  186. export declare function uuidv4(params?: string | core.$ZodUUIDv4Params): ZodUUID;
  187. export declare function uuidv6(params?: string | core.$ZodUUIDv6Params): ZodUUID;
  188. export declare function uuidv7(params?: string | core.$ZodUUIDv7Params): ZodUUID;
  189. export interface ZodURL extends ZodStringFormat<"url"> {
  190. _zod: core.$ZodURLInternals;
  191. }
  192. export declare const ZodURL: core.$constructor<ZodURL>;
  193. export declare function url(params?: string | core.$ZodURLParams): ZodURL;
  194. export declare function httpUrl(params?: string | Omit<core.$ZodURLParams, "protocol" | "hostname">): ZodURL;
  195. export interface ZodEmoji extends ZodStringFormat<"emoji"> {
  196. _zod: core.$ZodEmojiInternals;
  197. }
  198. export declare const ZodEmoji: core.$constructor<ZodEmoji>;
  199. export declare function emoji(params?: string | core.$ZodEmojiParams): ZodEmoji;
  200. export interface ZodNanoID extends ZodStringFormat<"nanoid"> {
  201. _zod: core.$ZodNanoIDInternals;
  202. }
  203. export declare const ZodNanoID: core.$constructor<ZodNanoID>;
  204. export declare function nanoid(params?: string | core.$ZodNanoIDParams): ZodNanoID;
  205. export interface ZodCUID extends ZodStringFormat<"cuid"> {
  206. _zod: core.$ZodCUIDInternals;
  207. }
  208. export declare const ZodCUID: core.$constructor<ZodCUID>;
  209. export declare function cuid(params?: string | core.$ZodCUIDParams): ZodCUID;
  210. export interface ZodCUID2 extends ZodStringFormat<"cuid2"> {
  211. _zod: core.$ZodCUID2Internals;
  212. }
  213. export declare const ZodCUID2: core.$constructor<ZodCUID2>;
  214. export declare function cuid2(params?: string | core.$ZodCUID2Params): ZodCUID2;
  215. export interface ZodULID extends ZodStringFormat<"ulid"> {
  216. _zod: core.$ZodULIDInternals;
  217. }
  218. export declare const ZodULID: core.$constructor<ZodULID>;
  219. export declare function ulid(params?: string | core.$ZodULIDParams): ZodULID;
  220. export interface ZodXID extends ZodStringFormat<"xid"> {
  221. _zod: core.$ZodXIDInternals;
  222. }
  223. export declare const ZodXID: core.$constructor<ZodXID>;
  224. export declare function xid(params?: string | core.$ZodXIDParams): ZodXID;
  225. export interface ZodKSUID extends ZodStringFormat<"ksuid"> {
  226. _zod: core.$ZodKSUIDInternals;
  227. }
  228. export declare const ZodKSUID: core.$constructor<ZodKSUID>;
  229. export declare function ksuid(params?: string | core.$ZodKSUIDParams): ZodKSUID;
  230. export interface ZodIPv4 extends ZodStringFormat<"ipv4"> {
  231. _zod: core.$ZodIPv4Internals;
  232. }
  233. export declare const ZodIPv4: core.$constructor<ZodIPv4>;
  234. export declare function ipv4(params?: string | core.$ZodIPv4Params): ZodIPv4;
  235. export interface ZodMAC extends ZodStringFormat<"mac"> {
  236. _zod: core.$ZodMACInternals;
  237. }
  238. export declare const ZodMAC: core.$constructor<ZodMAC>;
  239. export declare function mac(params?: string | core.$ZodMACParams): ZodMAC;
  240. export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
  241. _zod: core.$ZodIPv6Internals;
  242. }
  243. export declare const ZodIPv6: core.$constructor<ZodIPv6>;
  244. export declare function ipv6(params?: string | core.$ZodIPv6Params): ZodIPv6;
  245. export interface ZodCIDRv4 extends ZodStringFormat<"cidrv4"> {
  246. _zod: core.$ZodCIDRv4Internals;
  247. }
  248. export declare const ZodCIDRv4: core.$constructor<ZodCIDRv4>;
  249. export declare function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodCIDRv4;
  250. export interface ZodCIDRv6 extends ZodStringFormat<"cidrv6"> {
  251. _zod: core.$ZodCIDRv6Internals;
  252. }
  253. export declare const ZodCIDRv6: core.$constructor<ZodCIDRv6>;
  254. export declare function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodCIDRv6;
  255. export interface ZodBase64 extends ZodStringFormat<"base64"> {
  256. _zod: core.$ZodBase64Internals;
  257. }
  258. export declare const ZodBase64: core.$constructor<ZodBase64>;
  259. export declare function base64(params?: string | core.$ZodBase64Params): ZodBase64;
  260. export interface ZodBase64URL extends ZodStringFormat<"base64url"> {
  261. _zod: core.$ZodBase64URLInternals;
  262. }
  263. export declare const ZodBase64URL: core.$constructor<ZodBase64URL>;
  264. export declare function base64url(params?: string | core.$ZodBase64URLParams): ZodBase64URL;
  265. export interface ZodE164 extends ZodStringFormat<"e164"> {
  266. _zod: core.$ZodE164Internals;
  267. }
  268. export declare const ZodE164: core.$constructor<ZodE164>;
  269. export declare function e164(params?: string | core.$ZodE164Params): ZodE164;
  270. export interface ZodJWT extends ZodStringFormat<"jwt"> {
  271. _zod: core.$ZodJWTInternals;
  272. }
  273. export declare const ZodJWT: core.$constructor<ZodJWT>;
  274. export declare function jwt(params?: string | core.$ZodJWTParams): ZodJWT;
  275. export interface ZodCustomStringFormat<Format extends string = string> extends ZodStringFormat<Format>, core.$ZodCustomStringFormat<Format> {
  276. _zod: core.$ZodCustomStringFormatInternals<Format>;
  277. "~standard": ZodStandardSchemaWithJSON<this>;
  278. }
  279. export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
  280. export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
  281. export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
  282. export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
  283. export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
  284. enc?: Enc;
  285. } & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
  286. export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals> extends _ZodType<Internals> {
  287. gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
  288. /** Identical to .min() */
  289. gte(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
  290. min(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
  291. lt(value: number, params?: string | core.$ZodCheckLessThanParams): this;
  292. /** Identical to .max() */
  293. lte(value: number, params?: string | core.$ZodCheckLessThanParams): this;
  294. max(value: number, params?: string | core.$ZodCheckLessThanParams): this;
  295. /** Consider `z.int()` instead. This API is considered *legacy*; it will never be removed but a better alternative exists. */
  296. int(params?: string | core.$ZodCheckNumberFormatParams): this;
  297. /** @deprecated This is now identical to `.int()`. Only numbers in the safe integer range are accepted. */
  298. safe(params?: string | core.$ZodCheckNumberFormatParams): this;
  299. positive(params?: string | core.$ZodCheckGreaterThanParams): this;
  300. nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
  301. negative(params?: string | core.$ZodCheckLessThanParams): this;
  302. nonpositive(params?: string | core.$ZodCheckLessThanParams): this;
  303. multipleOf(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
  304. /** @deprecated Use `.multipleOf()` instead. */
  305. step(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
  306. /** @deprecated In v4 and later, z.number() does not allow infinite values by default. This is a no-op. */
  307. finite(params?: unknown): this;
  308. minValue: number | null;
  309. maxValue: number | null;
  310. /** @deprecated Check the `format` property instead. */
  311. isInt: boolean;
  312. /** @deprecated Number schemas no longer accept infinite values, so this always returns `true`. */
  313. isFinite: boolean;
  314. format: string | null;
  315. }
  316. export interface ZodNumber extends _ZodNumber<core.$ZodNumberInternals<number>> {
  317. }
  318. export declare const ZodNumber: core.$constructor<ZodNumber>;
  319. export declare function number(params?: string | core.$ZodNumberParams): ZodNumber;
  320. export interface ZodNumberFormat extends ZodNumber {
  321. _zod: core.$ZodNumberFormatInternals;
  322. }
  323. export declare const ZodNumberFormat: core.$constructor<ZodNumberFormat>;
  324. export interface ZodInt extends ZodNumberFormat {
  325. }
  326. export declare function int(params?: string | core.$ZodCheckNumberFormatParams): ZodInt;
  327. export interface ZodFloat32 extends ZodNumberFormat {
  328. }
  329. export declare function float32(params?: string | core.$ZodCheckNumberFormatParams): ZodFloat32;
  330. export interface ZodFloat64 extends ZodNumberFormat {
  331. }
  332. export declare function float64(params?: string | core.$ZodCheckNumberFormatParams): ZodFloat64;
  333. export interface ZodInt32 extends ZodNumberFormat {
  334. }
  335. export declare function int32(params?: string | core.$ZodCheckNumberFormatParams): ZodInt32;
  336. export interface ZodUInt32 extends ZodNumberFormat {
  337. }
  338. export declare function uint32(params?: string | core.$ZodCheckNumberFormatParams): ZodUInt32;
  339. export interface _ZodBoolean<T extends core.$ZodBooleanInternals = core.$ZodBooleanInternals> extends _ZodType<T> {
  340. }
  341. export interface ZodBoolean extends _ZodBoolean<core.$ZodBooleanInternals<boolean>> {
  342. }
  343. export declare const ZodBoolean: core.$constructor<ZodBoolean>;
  344. export declare function boolean(params?: string | core.$ZodBooleanParams): ZodBoolean;
  345. export interface _ZodBigInt<T extends core.$ZodBigIntInternals = core.$ZodBigIntInternals> extends _ZodType<T> {
  346. gte(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
  347. /** Alias of `.gte()` */
  348. min(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
  349. gt(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
  350. /** Alias of `.lte()` */
  351. lte(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
  352. max(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
  353. lt(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
  354. positive(params?: string | core.$ZodCheckGreaterThanParams): this;
  355. negative(params?: string | core.$ZodCheckLessThanParams): this;
  356. nonpositive(params?: string | core.$ZodCheckLessThanParams): this;
  357. nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
  358. multipleOf(value: bigint, params?: string | core.$ZodCheckMultipleOfParams): this;
  359. minValue: bigint | null;
  360. maxValue: bigint | null;
  361. format: string | null;
  362. }
  363. export interface ZodBigInt extends _ZodBigInt<core.$ZodBigIntInternals<bigint>> {
  364. }
  365. export declare const ZodBigInt: core.$constructor<ZodBigInt>;
  366. export declare function bigint(params?: string | core.$ZodBigIntParams): ZodBigInt;
  367. export interface ZodBigIntFormat extends ZodBigInt {
  368. _zod: core.$ZodBigIntFormatInternals;
  369. }
  370. export declare const ZodBigIntFormat: core.$constructor<ZodBigIntFormat>;
  371. export declare function int64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat;
  372. export declare function uint64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat;
  373. export interface ZodSymbol extends _ZodType<core.$ZodSymbolInternals> {
  374. }
  375. export declare const ZodSymbol: core.$constructor<ZodSymbol>;
  376. export declare function symbol(params?: string | core.$ZodSymbolParams): ZodSymbol;
  377. export interface ZodUndefined extends _ZodType<core.$ZodUndefinedInternals> {
  378. }
  379. export declare const ZodUndefined: core.$constructor<ZodUndefined>;
  380. declare function _undefined(params?: string | core.$ZodUndefinedParams): ZodUndefined;
  381. export { _undefined as undefined };
  382. export interface ZodNull extends _ZodType<core.$ZodNullInternals> {
  383. }
  384. export declare const ZodNull: core.$constructor<ZodNull>;
  385. declare function _null(params?: string | core.$ZodNullParams): ZodNull;
  386. export { _null as null };
  387. export interface ZodAny extends _ZodType<core.$ZodAnyInternals> {
  388. }
  389. export declare const ZodAny: core.$constructor<ZodAny>;
  390. export declare function any(): ZodAny;
  391. export interface ZodUnknown extends _ZodType<core.$ZodUnknownInternals> {
  392. }
  393. export declare const ZodUnknown: core.$constructor<ZodUnknown>;
  394. export declare function unknown(): ZodUnknown;
  395. export interface ZodNever extends _ZodType<core.$ZodNeverInternals> {
  396. }
  397. export declare const ZodNever: core.$constructor<ZodNever>;
  398. export declare function never(params?: string | core.$ZodNeverParams): ZodNever;
  399. export interface ZodVoid extends _ZodType<core.$ZodVoidInternals> {
  400. }
  401. export declare const ZodVoid: core.$constructor<ZodVoid>;
  402. declare function _void(params?: string | core.$ZodVoidParams): ZodVoid;
  403. export { _void as void };
  404. export interface _ZodDate<T extends core.$ZodDateInternals = core.$ZodDateInternals> extends _ZodType<T> {
  405. min(value: number | Date, params?: string | core.$ZodCheckGreaterThanParams): this;
  406. max(value: number | Date, params?: string | core.$ZodCheckLessThanParams): this;
  407. /** @deprecated Not recommended. */
  408. minDate: Date | null;
  409. /** @deprecated Not recommended. */
  410. maxDate: Date | null;
  411. }
  412. export interface ZodDate extends _ZodDate<core.$ZodDateInternals<Date>> {
  413. }
  414. export declare const ZodDate: core.$constructor<ZodDate>;
  415. export declare function date(params?: string | core.$ZodDateParams): ZodDate;
  416. export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodArrayInternals<T>>, core.$ZodArray<T> {
  417. element: T;
  418. min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
  419. nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
  420. max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
  421. length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
  422. unwrap(): T;
  423. "~standard": ZodStandardSchemaWithJSON<this>;
  424. }
  425. export declare const ZodArray: core.$constructor<ZodArray>;
  426. export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
  427. export declare function keyof<T extends ZodObject>(schema: T): ZodEnum<util.KeysEnum<T["_zod"]["output"]>>;
  428. export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
  429. [K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
  430. };
  431. export interface ZodObject<
  432. /** @ts-ignore Cast variance */
  433. out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
  434. "~standard": ZodStandardSchemaWithJSON<this>;
  435. shape: Shape;
  436. keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
  437. /** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
  438. catchall<T extends core.SomeType>(schema: T): ZodObject<Shape, core.$catchall<T>>;
  439. /** @deprecated Use `z.looseObject()` or `.loose()` instead. */
  440. passthrough(): ZodObject<Shape, core.$loose>;
  441. /** Consider `z.looseObject(A.shape)` instead */
  442. loose(): ZodObject<Shape, core.$loose>;
  443. /** Consider `z.strictObject(A.shape)` instead */
  444. strict(): ZodObject<Shape, core.$strict>;
  445. /** This is the default behavior. This method call is likely unnecessary. */
  446. strip(): ZodObject<Shape, core.$strip>;
  447. extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
  448. safeExtend<U extends core.$ZodLooseShape>(shape: SafeExtendShape<Shape, U> & Partial<Record<keyof Shape, core.SomeType>>): ZodObject<util.Extend<Shape, U>, Config>;
  449. /**
  450. * @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
  451. */
  452. merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
  453. pick<M extends util.Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
  454. omit<M extends util.Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
  455. partial(): ZodObject<{
  456. [k in keyof Shape]: ZodOptional<Shape[k]>;
  457. }, Config>;
  458. partial<M extends util.Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<{
  459. [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
  460. }, Config>;
  461. required(): ZodObject<{
  462. [k in keyof Shape]: ZodNonOptional<Shape[k]>;
  463. }, Config>;
  464. required<M extends util.Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<{
  465. [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
  466. }, Config>;
  467. }
  468. export declare const ZodObject: core.$constructor<ZodObject>;
  469. export declare function object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): ZodObject<util.Writeable<T>, core.$strip>;
  470. export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, core.$strict>;
  471. export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodObject<T, core.$loose>;
  472. export interface ZodUnion<T extends readonly core.SomeType[] = readonly core.$ZodType[]> extends _ZodType<core.$ZodUnionInternals<T>>, core.$ZodUnion<T> {
  473. "~standard": ZodStandardSchemaWithJSON<this>;
  474. options: T;
  475. }
  476. export declare const ZodUnion: core.$constructor<ZodUnion>;
  477. export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
  478. export interface ZodXor<T extends readonly core.SomeType[] = readonly core.$ZodType[]> extends _ZodType<core.$ZodXorInternals<T>>, core.$ZodXor<T> {
  479. "~standard": ZodStandardSchemaWithJSON<this>;
  480. options: T;
  481. }
  482. export declare const ZodXor: core.$constructor<ZodXor>;
  483. /** Creates an exclusive union (XOR) where exactly one option must match.
  484. * Unlike regular unions that succeed when any option matches, xor fails if
  485. * zero or more than one option matches the input. */
  486. export declare function xor<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodXorParams): ZodXor<T>;
  487. export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[], Disc extends string = string> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options, Disc> {
  488. "~standard": ZodStandardSchemaWithJSON<this>;
  489. _zod: core.$ZodDiscriminatedUnionInternals<Options, Disc>;
  490. def: core.$ZodDiscriminatedUnionDef<Options, Disc>;
  491. }
  492. export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
  493. export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types, Disc>;
  494. export interface ZodIntersection<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodIntersectionInternals<A, B>>, core.$ZodIntersection<A, B> {
  495. "~standard": ZodStandardSchemaWithJSON<this>;
  496. }
  497. export declare const ZodIntersection: core.$constructor<ZodIntersection>;
  498. export declare function intersection<T extends core.SomeType, U extends core.SomeType>(left: T, right: U): ZodIntersection<T, U>;
  499. export interface ZodTuple<T extends util.TupleItems = readonly core.$ZodType[], Rest extends core.SomeType | null = core.$ZodType | null> extends _ZodType<core.$ZodTupleInternals<T, Rest>>, core.$ZodTuple<T, Rest> {
  500. "~standard": ZodStandardSchemaWithJSON<this>;
  501. rest<Rest extends core.SomeType = core.$ZodType>(rest: Rest): ZodTuple<T, Rest>;
  502. }
  503. export declare const ZodTuple: core.$constructor<ZodTuple>;
  504. export declare function tuple<T extends readonly [core.SomeType, ...core.SomeType[]]>(items: T, params?: string | core.$ZodTupleParams): ZodTuple<T, null>;
  505. export declare function tuple<T extends readonly [core.SomeType, ...core.SomeType[]], Rest extends core.SomeType>(items: T, rest: Rest, params?: string | core.$ZodTupleParams): ZodTuple<T, Rest>;
  506. export declare function tuple(items: [], params?: string | core.$ZodTupleParams): ZodTuple<[], null>;
  507. export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodRecordInternals<Key, Value>>, core.$ZodRecord<Key, Value> {
  508. "~standard": ZodStandardSchemaWithJSON<this>;
  509. keyType: Key;
  510. valueType: Value;
  511. }
  512. export declare const ZodRecord: core.$constructor<ZodRecord>;
  513. export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
  514. export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key & core.$partial, Value>;
  515. export declare function looseRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
  516. export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
  517. "~standard": ZodStandardSchemaWithJSON<this>;
  518. keyType: Key;
  519. valueType: Value;
  520. min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
  521. nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
  522. max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
  523. size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
  524. }
  525. export declare const ZodMap: core.$constructor<ZodMap>;
  526. export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
  527. export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
  528. "~standard": ZodStandardSchemaWithJSON<this>;
  529. min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
  530. nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
  531. max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
  532. size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
  533. }
  534. export declare const ZodSet: core.$constructor<ZodSet>;
  535. export declare function set<Value extends core.SomeType>(valueType: Value, params?: string | core.$ZodSetParams): ZodSet<Value>;
  536. export interface ZodEnum<
  537. /** @ts-ignore Cast variance */
  538. out T extends util.EnumLike = util.EnumLike> extends _ZodType<core.$ZodEnumInternals<T>>, core.$ZodEnum<T> {
  539. "~standard": ZodStandardSchemaWithJSON<this>;
  540. enum: T;
  541. options: Array<T[keyof T]>;
  542. extract<const U extends readonly (keyof T)[]>(values: U, params?: string | core.$ZodEnumParams): ZodEnum<util.Flatten<Pick<T, U[number]>>>;
  543. exclude<const U extends readonly (keyof T)[]>(values: U, params?: string | core.$ZodEnumParams): ZodEnum<util.Flatten<Omit<T, U[number]>>>;
  544. }
  545. export declare const ZodEnum: core.$constructor<ZodEnum>;
  546. declare function _enum<const T extends readonly string[]>(values: T, params?: string | core.$ZodEnumParams): ZodEnum<util.ToEnum<T[number]>>;
  547. declare function _enum<const T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T>;
  548. export { _enum as enum };
  549. /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
  550. *
  551. * ```ts
  552. * enum Colors { red, green, blue }
  553. * z.enum(Colors);
  554. * ```
  555. */
  556. export declare function nativeEnum<T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T>;
  557. export interface ZodLiteral<T extends util.Literal = util.Literal> extends _ZodType<core.$ZodLiteralInternals<T>>, core.$ZodLiteral<T> {
  558. "~standard": ZodStandardSchemaWithJSON<this>;
  559. values: Set<T>;
  560. /** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
  561. value: T;
  562. }
  563. export declare const ZodLiteral: core.$constructor<ZodLiteral>;
  564. export declare function literal<const T extends ReadonlyArray<util.Literal>>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T[number]>;
  565. export declare function literal<const T extends util.Literal>(value: T, params?: string | core.$ZodLiteralParams): ZodLiteral<T>;
  566. export interface ZodFile extends _ZodType<core.$ZodFileInternals>, core.$ZodFile {
  567. "~standard": ZodStandardSchemaWithJSON<this>;
  568. min(size: number, params?: string | core.$ZodCheckMinSizeParams): this;
  569. max(size: number, params?: string | core.$ZodCheckMaxSizeParams): this;
  570. mime(types: util.MimeTypes | Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
  571. }
  572. export declare const ZodFile: core.$constructor<ZodFile>;
  573. export declare function file(params?: string | core.$ZodFileParams): ZodFile;
  574. export interface ZodTransform<O = unknown, I = unknown> extends _ZodType<core.$ZodTransformInternals<O, I>>, core.$ZodTransform<O, I> {
  575. "~standard": ZodStandardSchemaWithJSON<this>;
  576. }
  577. export declare const ZodTransform: core.$constructor<ZodTransform>;
  578. export declare function transform<I = unknown, O = I>(fn: (input: I, ctx: core.ParsePayload) => O): ZodTransform<Awaited<O>, I>;
  579. export interface ZodOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodOptionalInternals<T>>, core.$ZodOptional<T> {
  580. "~standard": ZodStandardSchemaWithJSON<this>;
  581. unwrap(): T;
  582. }
  583. export declare const ZodOptional: core.$constructor<ZodOptional>;
  584. export declare function optional<T extends core.SomeType>(innerType: T): ZodOptional<T>;
  585. export interface ZodExactOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodExactOptionalInternals<T>>, core.$ZodExactOptional<T> {
  586. "~standard": ZodStandardSchemaWithJSON<this>;
  587. unwrap(): T;
  588. }
  589. export declare const ZodExactOptional: core.$constructor<ZodExactOptional>;
  590. export declare function exactOptional<T extends core.SomeType>(innerType: T): ZodExactOptional<T>;
  591. export interface ZodNullable<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodNullableInternals<T>>, core.$ZodNullable<T> {
  592. "~standard": ZodStandardSchemaWithJSON<this>;
  593. unwrap(): T;
  594. }
  595. export declare const ZodNullable: core.$constructor<ZodNullable>;
  596. export declare function nullable<T extends core.SomeType>(innerType: T): ZodNullable<T>;
  597. export declare function nullish<T extends core.SomeType>(innerType: T): ZodOptional<ZodNullable<T>>;
  598. export interface ZodDefault<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodDefaultInternals<T>>, core.$ZodDefault<T> {
  599. "~standard": ZodStandardSchemaWithJSON<this>;
  600. unwrap(): T;
  601. /** @deprecated Use `.unwrap()` instead. */
  602. removeDefault(): T;
  603. }
  604. export declare const ZodDefault: core.$constructor<ZodDefault>;
  605. export declare function _default<T extends core.SomeType>(innerType: T, defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)): ZodDefault<T>;
  606. export interface ZodPrefault<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPrefaultInternals<T>>, core.$ZodPrefault<T> {
  607. "~standard": ZodStandardSchemaWithJSON<this>;
  608. unwrap(): T;
  609. }
  610. export declare const ZodPrefault: core.$constructor<ZodPrefault>;
  611. export declare function prefault<T extends core.SomeType>(innerType: T, defaultValue: core.input<T> | (() => core.input<T>)): ZodPrefault<T>;
  612. export interface ZodNonOptional<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodNonOptionalInternals<T>>, core.$ZodNonOptional<T> {
  613. "~standard": ZodStandardSchemaWithJSON<this>;
  614. unwrap(): T;
  615. }
  616. export declare const ZodNonOptional: core.$constructor<ZodNonOptional>;
  617. export declare function nonoptional<T extends core.SomeType>(innerType: T, params?: string | core.$ZodNonOptionalParams): ZodNonOptional<T>;
  618. export interface ZodSuccess<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSuccessInternals<T>>, core.$ZodSuccess<T> {
  619. "~standard": ZodStandardSchemaWithJSON<this>;
  620. unwrap(): T;
  621. }
  622. export declare const ZodSuccess: core.$constructor<ZodSuccess>;
  623. export declare function success<T extends core.SomeType>(innerType: T): ZodSuccess<T>;
  624. export interface ZodCatch<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodCatchInternals<T>>, core.$ZodCatch<T> {
  625. "~standard": ZodStandardSchemaWithJSON<this>;
  626. unwrap(): T;
  627. /** @deprecated Use `.unwrap()` instead. */
  628. removeCatch(): T;
  629. }
  630. export declare const ZodCatch: core.$constructor<ZodCatch>;
  631. declare function _catch<T extends core.SomeType>(innerType: T, catchValue: core.output<T> | ((ctx: core.$ZodCatchCtx) => core.output<T>)): ZodCatch<T>;
  632. export { _catch as catch };
  633. export interface ZodNaN extends _ZodType<core.$ZodNaNInternals>, core.$ZodNaN {
  634. "~standard": ZodStandardSchemaWithJSON<this>;
  635. }
  636. export declare const ZodNaN: core.$constructor<ZodNaN>;
  637. export declare function nan(params?: string | core.$ZodNaNParams): ZodNaN;
  638. export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPipeInternals<A, B>>, core.$ZodPipe<A, B> {
  639. "~standard": ZodStandardSchemaWithJSON<this>;
  640. in: A;
  641. out: B;
  642. }
  643. export declare const ZodPipe: core.$constructor<ZodPipe>;
  644. export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
  645. export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends ZodPipe<A, B>, core.$ZodCodec<A, B> {
  646. "~standard": ZodStandardSchemaWithJSON<this>;
  647. _zod: core.$ZodCodecInternals<A, B>;
  648. def: core.$ZodCodecDef<A, B>;
  649. }
  650. export declare const ZodCodec: core.$constructor<ZodCodec>;
  651. export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
  652. decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
  653. encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
  654. }): ZodCodec<A, B>;
  655. export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
  656. "~standard": ZodStandardSchemaWithJSON<this>;
  657. unwrap(): T;
  658. }
  659. export declare const ZodReadonly: core.$constructor<ZodReadonly>;
  660. export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
  661. export interface ZodTemplateLiteral<Template extends string = string> extends _ZodType<core.$ZodTemplateLiteralInternals<Template>>, core.$ZodTemplateLiteral<Template> {
  662. "~standard": ZodStandardSchemaWithJSON<this>;
  663. }
  664. export declare const ZodTemplateLiteral: core.$constructor<ZodTemplateLiteral>;
  665. export declare function templateLiteral<const Parts extends core.$ZodTemplateLiteralPart[]>(parts: Parts, params?: string | core.$ZodTemplateLiteralParams): ZodTemplateLiteral<core.$PartsToTemplateLiteral<Parts>>;
  666. export interface ZodLazy<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodLazyInternals<T>>, core.$ZodLazy<T> {
  667. "~standard": ZodStandardSchemaWithJSON<this>;
  668. unwrap(): T;
  669. }
  670. export declare const ZodLazy: core.$constructor<ZodLazy>;
  671. export declare function lazy<T extends core.SomeType>(getter: () => T): ZodLazy<T>;
  672. export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodPromiseInternals<T>>, core.$ZodPromise<T> {
  673. "~standard": ZodStandardSchemaWithJSON<this>;
  674. unwrap(): T;
  675. }
  676. export declare const ZodPromise: core.$constructor<ZodPromise>;
  677. export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
  678. export interface ZodFunction<Args extends core.$ZodFunctionIn = core.$ZodFunctionIn, Returns extends core.$ZodFunctionOut = core.$ZodFunctionOut> extends _ZodType<core.$ZodFunctionInternals<Args, Returns>>, core.$ZodFunction<Args, Returns> {
  679. "~standard": ZodStandardSchemaWithJSON<this>;
  680. _def: core.$ZodFunctionDef<Args, Returns>;
  681. _input: core.$InferInnerFunctionType<Args, Returns>;
  682. _output: core.$InferOuterFunctionType<Args, Returns>;
  683. input<const Items extends util.TupleItems, const Rest extends core.$ZodFunctionOut = core.$ZodFunctionOut>(args: Items, rest?: Rest): ZodFunction<core.$ZodTuple<Items, Rest>, Returns>;
  684. input<NewArgs extends core.$ZodFunctionIn>(args: NewArgs): ZodFunction<NewArgs, Returns>;
  685. input(...args: any[]): ZodFunction<any, Returns>;
  686. output<NewReturns extends core.$ZodType>(output: NewReturns): ZodFunction<Args, NewReturns>;
  687. }
  688. export declare const ZodFunction: core.$constructor<ZodFunction>;
  689. export declare function _function(): ZodFunction;
  690. export declare function _function<const In extends ReadonlyArray<core.$ZodType>>(params: {
  691. input: In;
  692. }): ZodFunction<ZodTuple<In, null>, core.$ZodFunctionOut>;
  693. export declare function _function<const In extends ReadonlyArray<core.$ZodType>, const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
  694. input: In;
  695. output: Out;
  696. }): ZodFunction<ZodTuple<In, null>, Out>;
  697. export declare function _function<const In extends core.$ZodFunctionIn = core.$ZodFunctionIn>(params: {
  698. input: In;
  699. }): ZodFunction<In, core.$ZodFunctionOut>;
  700. export declare function _function<const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
  701. output: Out;
  702. }): ZodFunction<core.$ZodFunctionIn, Out>;
  703. export declare function _function<In extends core.$ZodFunctionIn = core.$ZodFunctionIn, Out extends core.$ZodType = core.$ZodType>(params?: {
  704. input: In;
  705. output: Out;
  706. }): ZodFunction<In, Out>;
  707. export { _function as function };
  708. export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
  709. "~standard": ZodStandardSchemaWithJSON<this>;
  710. }
  711. export declare const ZodCustom: core.$constructor<ZodCustom>;
  712. export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
  713. export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
  714. export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
  715. export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
  716. export declare const describe: typeof core.describe;
  717. export declare const meta: typeof core.meta;
  718. type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
  719. declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
  720. export { _instanceof as instanceof };
  721. export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
  722. type _ZodJSONSchema = ZodUnion<[
  723. ZodString,
  724. ZodNumber,
  725. ZodBoolean,
  726. ZodNull,
  727. ZodArray<ZodJSONSchema>,
  728. ZodRecord<ZodString, ZodJSONSchema>
  729. ]>;
  730. type _ZodJSONSchemaInternals = _ZodJSONSchema["_zod"];
  731. export interface ZodJSONSchemaInternals extends _ZodJSONSchemaInternals {
  732. output: util.JSONType;
  733. input: util.JSONType;
  734. }
  735. export interface ZodJSONSchema extends _ZodJSONSchema {
  736. _zod: ZodJSONSchemaInternals;
  737. }
  738. export declare function json(params?: string | core.$ZodCustomParams): ZodJSONSchema;
  739. export declare function preprocess<A, U extends core.SomeType, B = unknown>(fn: (arg: B, ctx: core.$RefinementCtx) => A, schema: U): ZodPipe<ZodTransform<A, B>, U>;