LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • data_object
      JSON Schema
    • format_quote
      String

    • error
      Stack

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
zod/v3 (default)/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/zod/v3/download_compiled/default/minified.js
code_off
View RawView Raw
Copy to clipboardCopy to clipboard
var e = Object.defineProperty, t = (t, n) => { let r = {}; for (var i in t) e(r, i, { get: t[i], enumerable: !0 }); return (n || e(r, Symbol.toStringTag, { value: `Module` }), r); }, n; (function (e) { e.assertEqual = (e) => {}; function t(e) {} e.assertIs = t; function n(e) { throw Error(); } ((e.assertNever = n), (e.arrayToEnum = (e) => { let t = {}; for (let n of e) t[n] = n; return t; }), (e.getValidEnumValues = (t) => { let n = e.objectKeys(t).filter((e) => typeof t[t[e]] != `number`), r = {}; for (let e of n) r[e] = t[e]; return e.objectValues(r); }), (e.objectValues = (t) => e.objectKeys(t).map(function (e) { return t[e]; })), (e.objectKeys = typeof Object.keys == `function` ? (e) => Object.keys(e) : (e) => { let t = []; for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && t.push(n); return t; }), (e.find = (e, t) => { for (let n of e) if (t(n)) return n; }), (e.isInteger = typeof Number.isInteger == `function` ? (e) => Number.isInteger(e) : (e) => typeof e == `number` && Number.isFinite(e) && Math.floor(e) === e)); function r(e, t = ` | `) { return e.map((e) => (typeof e == `string` ? `'${e}'` : e)).join(t); } ((e.joinValues = r), (e.jsonStringifyReplacer = (e, t) => (typeof t == `bigint` ? t.toString() : t))); })((n ||= {})); var r; (function (e) { e.mergeShapes = (e, t) => ({ ...e, ...t }); })((r ||= {})); const i = n.arrayToEnum([ `string`, `nan`, `number`, `integer`, `float`, `boolean`, `date`, `bigint`, `symbol`, `function`, `undefined`, `null`, `array`, `object`, `unknown`, `promise`, `void`, `never`, `map`, `set`, ]), a = (e) => { switch (typeof e) { case `undefined`: return i.undefined; case `string`: return i.string; case `number`: return Number.isNaN(e) ? i.nan : i.number; case `boolean`: return i.boolean; case `function`: return i.function; case `bigint`: return i.bigint; case `symbol`: return i.symbol; case `object`: return Array.isArray(e) ? i.array : e === null ? i.null : e.then && typeof e.then == `function` && e.catch && typeof e.catch == `function` ? i.promise : typeof Map < `u` && e instanceof Map ? i.map : typeof Set < `u` && e instanceof Set ? i.set : typeof Date < `u` && e instanceof Date ? i.date : i.object; default: return i.unknown; } }, o = n.arrayToEnum([ `invalid_type`, `invalid_literal`, `custom`, `invalid_union`, `invalid_union_discriminator`, `invalid_enum_value`, `unrecognized_keys`, `invalid_arguments`, `invalid_return_type`, `invalid_date`, `invalid_string`, `too_small`, `too_big`, `invalid_intersection_types`, `not_multiple_of`, `not_finite`, ]), s = (e) => JSON.stringify(e, null, 2).replace(/"([^"]+)":/g, `$1:`); var c = class e extends Error { get errors() { return this.issues; } constructor(e) { (super(), (this.issues = []), (this.addIssue = (e) => { this.issues = [...this.issues, e]; }), (this.addIssues = (e = []) => { this.issues = [...this.issues, ...e]; })); let t = new.target.prototype; (Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : (this.__proto__ = t), (this.name = `ZodError`), (this.issues = e)); } format(e) { let t = e || function (e) { return e.message; }, n = { _errors: [] }, r = (e) => { for (let i of e.issues) if (i.code === `invalid_union`) i.unionErrors.map(r); else if (i.code === `invalid_return_type`) r(i.returnTypeError); else if (i.code === `invalid_arguments`) r(i.argumentsError); else if (i.path.length === 0) n._errors.push(t(i)); else { let e = n, r = 0; for (; r < i.path.length;) { let n = i.path[r]; (r === i.path.length - 1 ? ((e[n] = e[n] || { _errors: [] }), e[n]._errors.push(t(i))) : (e[n] = e[n] || { _errors: [] }), (e = e[n]), r++); } } }; return (r(this), n); } static assert(t) { if (!(t instanceof e)) throw Error(`Not a ZodError: ${t}`); } toString() { return this.message; } get message() { return JSON.stringify(this.issues, n.jsonStringifyReplacer, 2); } get isEmpty() { return this.issues.length === 0; } flatten(e = (e) => e.message) { let t = Object.create(null), n = []; for (let r of this.issues) if (r.path.length > 0) { let n = r.path[0]; ((t[n] = t[n] || []), t[n].push(e(r))); } else n.push(e(r)); return { formErrors: n, fieldErrors: t }; } get formErrors() { return this.flatten(); } }; c.create = (e) => new c(e); const l = (e, t) => { let r; switch (e.code) { case o.invalid_type: r = e.received === i.undefined ? `Required` : `Expected ${e.expected}, received ${e.received}`; break; case o.invalid_literal: r = `Invalid literal value, expected ${JSON.stringify(e.expected, n.jsonStringifyReplacer)}`; break; case o.unrecognized_keys: r = `Unrecognized key(s) in object: ${n.joinValues(e.keys, `, `)}`; break; case o.invalid_union: r = `Invalid input`; break; case o.invalid_union_discriminator: r = `Invalid discriminator value. Expected ${n.joinValues(e.options)}`; break; case o.invalid_enum_value: r = `Invalid enum value. Expected ${n.joinValues(e.options)}, received '${e.received}'`; break; case o.invalid_arguments: r = `Invalid function arguments`; break; case o.invalid_return_type: r = `Invalid function return type`; break; case o.invalid_date: r = `Invalid date`; break; case o.invalid_string: typeof e.validation == `object` ? `includes` in e.validation ? ((r = `Invalid input: must include "${e.validation.includes}"`), typeof e.validation.position == `number` && (r = `${r} at one or more positions greater than or equal to ${e.validation.position}`)) : `startsWith` in e.validation ? (r = `Invalid input: must start with "${e.validation.startsWith}"`) : `endsWith` in e.validation ? (r = `Invalid input: must end with "${e.validation.endsWith}"`) : n.assertNever(e.validation) : (r = e.validation === `regex` ? `Invalid` : `Invalid ${e.validation}`); break; case o.too_small: r = e.type === `array` ? `Array must contain ${e.exact ? `exactly` : e.inclusive ? `at least` : `more than`} ${e.minimum} element(s)` : e.type === `string` ? `String must contain ${e.exact ? `exactly` : e.inclusive ? `at least` : `over`} ${e.minimum} character(s)` : e.type === `number` || e.type === `bigint` ? `Number must be ${e.exact ? `exactly equal to ` : e.inclusive ? `greater than or equal to ` : `greater than `}${e.minimum}` : e.type === `date` ? `Date must be ${e.exact ? `exactly equal to ` : e.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(e.minimum))}` : `Invalid input`; break; case o.too_big: r = e.type === `array` ? `Array must contain ${e.exact ? `exactly` : e.inclusive ? `at most` : `less than`} ${e.maximum} element(s)` : e.type === `string` ? `String must contain ${e.exact ? `exactly` : e.inclusive ? `at most` : `under`} ${e.maximum} character(s)` : e.type === `number` ? `Number must be ${e.exact ? `exactly` : e.inclusive ? `less than or equal to` : `less than`} ${e.maximum}` : e.type === `bigint` ? `BigInt must be ${e.exact ? `exactly` : e.inclusive ? `less than or equal to` : `less than`} ${e.maximum}` : e.type === `date` ? `Date must be ${e.exact ? `exactly` : e.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(e.maximum))}` : `Invalid input`; break; case o.custom: r = `Invalid input`; break; case o.invalid_intersection_types: r = `Intersection results could not be merged`; break; case o.not_multiple_of: r = `Number must be a multiple of ${e.multipleOf}`; break; case o.not_finite: r = `Number must be finite`; break; default: ((r = t.defaultError), n.assertNever(e)); } return { message: r }; }; let ee = l; function te(e) { ee = e; } function u() { return ee; } const d = (e) => { let { data: t, path: n, errorMaps: r, issueData: i } = e, a = [...n, ...(i.path || [])], o = { ...i, path: a }; if (i.message !== void 0) return { ...i, path: a, message: i.message }; let s = ``, c = r .filter((e) => !!e) .slice() .reverse(); for (let e of c) s = e(o, { data: t, defaultError: s }).message; return { ...i, path: a, message: s }; }, ne = []; function f(e, t) { let n = u(), r = d({ issueData: t, data: e.data, path: e.path, errorMaps: [e.common.contextualErrorMap, e.schemaErrorMap, n, n === l ? void 0 : l].filter( (e) => !!e, ), }); e.common.issues.push(r); } var p = class e { constructor() { this.value = `valid`; } dirty() { this.value === `valid` && (this.value = `dirty`); } abort() { this.value !== `aborted` && (this.value = `aborted`); } static mergeArray(e, t) { let n = []; for (let r of t) { if (r.status === `aborted`) return m; (r.status === `dirty` && e.dirty(), n.push(r.value)); } return { status: e.value, value: n }; } static async mergeObjectAsync(t, n) { let r = []; for (let e of n) { let t = await e.key, n = await e.value; r.push({ key: t, value: n }); } return e.mergeObjectSync(t, r); } static mergeObjectSync(e, t) { let n = {}; for (let r of t) { let { key: t, value: i } = r; if (t.status === `aborted` || i.status === `aborted`) return m; (t.status === `dirty` && e.dirty(), i.status === `dirty` && e.dirty(), t.value !== `__proto__` && (i.value !== void 0 || r.alwaysSet) && (n[t.value] = i.value)); } return { status: e.value, value: n }; } }; const m = Object.freeze({ status: `aborted` }), re = (e) => ({ status: `dirty`, value: e }), h = (e) => ({ status: `valid`, value: e }), ie = (e) => e.status === `aborted`, ae = (e) => e.status === `dirty`, g = (e) => e.status === `valid`, _ = (e) => typeof Promise < `u` && e instanceof Promise; var v; (function (e) { ((e.errToObj = (e) => (typeof e == `string` ? { message: e } : e || {})), (e.toString = (e) => (typeof e == `string` ? e : e?.message))); })((v ||= {})); var y = class { constructor(e, t, n, r) { ((this._cachedPath = []), (this.parent = e), (this.data = t), (this._path = n), (this._key = r)); } get path() { return ( this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath ); } }; const oe = (e, t) => { if (g(t)) return { success: !0, data: t.value }; if (!e.common.issues.length) throw Error(`Validation failed but no issues detected.`); return { success: !1, get error() { if (this._error) return this._error; let t = new c(e.common.issues); return ((this._error = t), this._error); }, }; }; function b(e) { if (!e) return {}; let { errorMap: t, invalid_type_error: n, required_error: r, description: i } = e; if (t && (n || r)) throw Error( `Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`, ); return t ? { errorMap: t, description: i } : { errorMap: (t, i) => { let { message: a } = e; return t.code === `invalid_enum_value` ? { message: a ?? i.defaultError } : i.data === void 0 ? { message: a ?? r ?? i.defaultError } : t.code === `invalid_type` ? { message: a ?? n ?? i.defaultError } : { message: i.defaultError }; }, description: i, }; } var x = class { get description() { return this._def.description; } _getType(e) { return a(e.data); } _getOrReturnCtx(e, t) { return ( t || { common: e.parent.common, data: e.data, parsedType: a(e.data), schemaErrorMap: this._def.errorMap, path: e.path, parent: e.parent, } ); } _processInputParams(e) { return { status: new p(), ctx: { common: e.parent.common, data: e.data, parsedType: a(e.data), schemaErrorMap: this._def.errorMap, path: e.path, parent: e.parent, }, }; } _parseSync(e) { let t = this._parse(e); if (_(t)) throw Error(`Synchronous parse encountered promise.`); return t; } _parseAsync(e) { let t = this._parse(e); return Promise.resolve(t); } parse(e, t) { let n = this.safeParse(e, t); if (n.success) return n.data; throw n.error; } safeParse(e, t) { let n = { common: { issues: [], async: t?.async ?? !1, contextualErrorMap: t?.errorMap }, path: t?.path || [], schemaErrorMap: this._def.errorMap, parent: null, data: e, parsedType: a(e), }, r = this._parseSync({ data: e, path: n.path, parent: n }); return oe(n, r); } "~validate"(e) { let t = { common: { issues: [], async: !!this[`~standard`].async }, path: [], schemaErrorMap: this._def.errorMap, parent: null, data: e, parsedType: a(e), }; if (!this[`~standard`].async) try { let n = this._parseSync({ data: e, path: [], parent: t }); return g(n) ? { value: n.value } : { issues: t.common.issues }; } catch (e) { (e?.message?.toLowerCase()?.includes(`encountered`) && (this[`~standard`].async = !0), (t.common = { issues: [], async: !0 })); } return this._parseAsync({ data: e, path: [], parent: t }).then((e) => g(e) ? { value: e.value } : { issues: t.common.issues }, ); } async parseAsync(e, t) { let n = await this.safeParseAsync(e, t); if (n.success) return n.data; throw n.error; } async safeParseAsync(e, t) { let n = { common: { issues: [], contextualErrorMap: t?.errorMap, async: !0 }, path: t?.path || [], schemaErrorMap: this._def.errorMap, parent: null, data: e, parsedType: a(e), }, r = this._parse({ data: e, path: n.path, parent: n }), i = await (_(r) ? r : Promise.resolve(r)); return oe(n, i); } refine(e, t) { let n = (e) => typeof t == `string` || t === void 0 ? { message: t } : typeof t == `function` ? t(e) : t; return this._refinement((t, r) => { let i = e(t), a = () => r.addIssue({ code: o.custom, ...n(t) }); return typeof Promise < `u` && i instanceof Promise ? i.then((e) => (e ? !0 : (a(), !1))) : i ? !0 : (a(), !1); }); } refinement(e, t) { return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof t == `function` ? t(n, r) : t), !1), ); } _refinement(e) { return new K({ schema: this, typeName: Q.ZodEffects, effect: { type: `refinement`, refinement: e }, }); } superRefine(e) { return this._refinement(e); } constructor(e) { ((this.spa = this.safeParseAsync), (this._def = e), (this.parse = this.parse.bind(this)), (this.safeParse = this.safeParse.bind(this)), (this.parseAsync = this.parseAsync.bind(this)), (this.safeParseAsync = this.safeParseAsync.bind(this)), (this.spa = this.spa.bind(this)), (this.refine = this.refine.bind(this)), (this.refinement = this.refinement.bind(this)), (this.superRefine = this.superRefine.bind(this)), (this.optional = this.optional.bind(this)), (this.nullable = this.nullable.bind(this)), (this.nullish = this.nullish.bind(this)), (this.array = this.array.bind(this)), (this.promise = this.promise.bind(this)), (this.or = this.or.bind(this)), (this.and = this.and.bind(this)), (this.transform = this.transform.bind(this)), (this.brand = this.brand.bind(this)), (this.default = this.default.bind(this)), (this.catch = this.catch.bind(this)), (this.describe = this.describe.bind(this)), (this.pipe = this.pipe.bind(this)), (this.readonly = this.readonly.bind(this)), (this.isNullable = this.isNullable.bind(this)), (this.isOptional = this.isOptional.bind(this)), (this[`~standard`] = { version: 1, vendor: `zod`, validate: (e) => this[`~validate`](e) })); } optional() { return q.create(this, this._def); } nullable() { return J.create(this, this._def); } nullish() { return this.nullable().optional(); } array() { return P.create(this); } promise() { return G.create(this, this._def); } or(e) { return L.create([this, e], this._def); } and(e) { return z.create(this, e, this._def); } transform(e) { return new K({ ...b(this._def), schema: this, typeName: Q.ZodEffects, effect: { type: `transform`, transform: e }, }); } default(e) { let t = typeof e == `function` ? e : () => e; return new Y({ ...b(this._def), innerType: this, defaultValue: t, typeName: Q.ZodDefault }); } brand() { return new Be({ typeName: Q.ZodBranded, type: this, ...b(this._def) }); } catch(e) { let t = typeof e == `function` ? e : () => e; return new X({ ...b(this._def), innerType: this, catchValue: t, typeName: Q.ZodCatch }); } describe(e) { let t = this.constructor; return new t({ ...this._def, description: e }); } pipe(e) { return Ve.create(this, e); } readonly() { return Z.create(this); } isOptional() { return this.safeParse(void 0).success; } isNullable() { return this.safeParse(null).success; } }; const se = /^c[^\s-]{8,}$/i, ce = /^[0-9a-z]+$/, le = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ue = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, de = /^[a-z0-9_-]{21}$/i, fe = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, pe = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, me = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i; let he; const ge = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, _e = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, ve = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, ye = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, be = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, xe = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Se = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`, Ce = RegExp(`^${Se}$`); function we(e) { let t = `[0-5]\\d`; e.precision ? (t = `${t}\\.\\d{${e.precision}}`) : (e.precision ?? (t = `${t}(\\.\\d+)?`)); let n = e.precision ? `+` : `?`; return `([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`; } function Te(e) { return RegExp(`^${we(e)}$`); } function Ee(e) { let t = `${Se}T${we(e)}`, n = []; return ( n.push(e.local ? `Z?` : `Z`), e.offset && n.push(`([+-]\\d{2}:?\\d{2})`), (t = `${t}(${n.join(`|`)})`), RegExp(`^${t}$`) ); } function De(e, t) { return !!(((t === `v4` || !t) && ge.test(e)) || ((t === `v6` || !t) && ve.test(e))); } function Oe(e, t) { if (!fe.test(e)) return !1; try { let [n] = e.split(`.`); if (!n) return !1; let r = n .replace(/-/g, `+`) .replace(/_/g, `/`) .padEnd(n.length + ((4 - (n.length % 4)) % 4), `=`), i = JSON.parse(atob(r)); return !( typeof i != `object` || !i || (`typ` in i && i?.typ !== `JWT`) || !i.alg || (t && i.alg !== t) ); } catch { return !1; } } function ke(e, t) { return !!(((t === `v4` || !t) && _e.test(e)) || ((t === `v6` || !t) && ye.test(e))); } var S = class e extends x { _parse(e) { if ((this._def.coerce && (e.data = String(e.data)), this._getType(e) !== i.string)) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.string, received: t.parsedType }), m); } let t = new p(), r; for (let i of this._def.checks) if (i.kind === `min`) e.data.length < i.value && ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.too_small, minimum: i.value, type: `string`, inclusive: !0, exact: !1, message: i.message, }), t.dirty()); else if (i.kind === `max`) e.data.length > i.value && ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.too_big, maximum: i.value, type: `string`, inclusive: !0, exact: !1, message: i.message, }), t.dirty()); else if (i.kind === `length`) { let n = e.data.length > i.value, a = e.data.length < i.value; (n || a) && ((r = this._getOrReturnCtx(e, r)), n ? f(r, { code: o.too_big, maximum: i.value, type: `string`, inclusive: !0, exact: !0, message: i.message, }) : a && f(r, { code: o.too_small, minimum: i.value, type: `string`, inclusive: !0, exact: !0, message: i.message, }), t.dirty()); } else if (i.kind === `email`) me.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `email`, code: o.invalid_string, message: i.message }), t.dirty()); else if (i.kind === `emoji`) ((he ||= RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`, `u`)), he.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `emoji`, code: o.invalid_string, message: i.message }), t.dirty())); else if (i.kind === `uuid`) ue.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `uuid`, code: o.invalid_string, message: i.message }), t.dirty()); else if (i.kind === `nanoid`) de.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `nanoid`, code: o.invalid_string, message: i.message }), t.dirty()); else if (i.kind === `cuid`) se.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `cuid`, code: o.invalid_string, message: i.message }), t.dirty()); else if (i.kind === `cuid2`) ce.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `cuid2`, code: o.invalid_string, message: i.message }), t.dirty()); else if (i.kind === `ulid`) le.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `ulid`, code: o.invalid_string, message: i.message }), t.dirty()); else if (i.kind === `url`) try { new URL(e.data); } catch { ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `url`, code: o.invalid_string, message: i.message }), t.dirty()); } else i.kind === `regex` ? ((i.regex.lastIndex = 0), i.regex.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `regex`, code: o.invalid_string, message: i.message }), t.dirty())) : i.kind === `trim` ? (e.data = e.data.trim()) : i.kind === `includes` ? e.data.includes(i.value, i.position) || ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.invalid_string, validation: { includes: i.value, position: i.position }, message: i.message, }), t.dirty()) : i.kind === `toLowerCase` ? (e.data = e.data.toLowerCase()) : i.kind === `toUpperCase` ? (e.data = e.data.toUpperCase()) : i.kind === `startsWith` ? e.data.startsWith(i.value) || ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.invalid_string, validation: { startsWith: i.value }, message: i.message, }), t.dirty()) : i.kind === `endsWith` ? e.data.endsWith(i.value) || ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.invalid_string, validation: { endsWith: i.value }, message: i.message, }), t.dirty()) : i.kind === `datetime` ? Ee(i).test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.invalid_string, validation: `datetime`, message: i.message, }), t.dirty()) : i.kind === `date` ? Ce.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.invalid_string, validation: `date`, message: i.message, }), t.dirty()) : i.kind === `time` ? Te(i).test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.invalid_string, validation: `time`, message: i.message, }), t.dirty()) : i.kind === `duration` ? pe.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `duration`, code: o.invalid_string, message: i.message, }), t.dirty()) : i.kind === `ip` ? De(e.data, i.version) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `ip`, code: o.invalid_string, message: i.message, }), t.dirty()) : i.kind === `jwt` ? Oe(e.data, i.alg) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `jwt`, code: o.invalid_string, message: i.message, }), t.dirty()) : i.kind === `cidr` ? ke(e.data, i.version) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `cidr`, code: o.invalid_string, message: i.message, }), t.dirty()) : i.kind === `base64` ? be.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `base64`, code: o.invalid_string, message: i.message, }), t.dirty()) : i.kind === `base64url` ? xe.test(e.data) || ((r = this._getOrReturnCtx(e, r)), f(r, { validation: `base64url`, code: o.invalid_string, message: i.message, }), t.dirty()) : n.assertNever(i); return { status: t.value, value: e.data }; } _regex(e, t, n) { return this.refinement((t) => e.test(t), { validation: t, code: o.invalid_string, ...v.errToObj(n), }); } _addCheck(t) { return new e({ ...this._def, checks: [...this._def.checks, t] }); } email(e) { return this._addCheck({ kind: `email`, ...v.errToObj(e) }); } url(e) { return this._addCheck({ kind: `url`, ...v.errToObj(e) }); } emoji(e) { return this._addCheck({ kind: `emoji`, ...v.errToObj(e) }); } uuid(e) { return this._addCheck({ kind: `uuid`, ...v.errToObj(e) }); } nanoid(e) { return this._addCheck({ kind: `nanoid`, ...v.errToObj(e) }); } cuid(e) { return this._addCheck({ kind: `cuid`, ...v.errToObj(e) }); } cuid2(e) { return this._addCheck({ kind: `cuid2`, ...v.errToObj(e) }); } ulid(e) { return this._addCheck({ kind: `ulid`, ...v.errToObj(e) }); } base64(e) { return this._addCheck({ kind: `base64`, ...v.errToObj(e) }); } base64url(e) { return this._addCheck({ kind: `base64url`, ...v.errToObj(e) }); } jwt(e) { return this._addCheck({ kind: `jwt`, ...v.errToObj(e) }); } ip(e) { return this._addCheck({ kind: `ip`, ...v.errToObj(e) }); } cidr(e) { return this._addCheck({ kind: `cidr`, ...v.errToObj(e) }); } datetime(e) { return typeof e == `string` ? this._addCheck({ kind: `datetime`, precision: null, offset: !1, local: !1, message: e }) : this._addCheck({ kind: `datetime`, precision: e?.precision === void 0 ? null : e?.precision, offset: e?.offset ?? !1, local: e?.local ?? !1, ...v.errToObj(e?.message), }); } date(e) { return this._addCheck({ kind: `date`, message: e }); } time(e) { return typeof e == `string` ? this._addCheck({ kind: `time`, precision: null, message: e }) : this._addCheck({ kind: `time`, precision: e?.precision === void 0 ? null : e?.precision, ...v.errToObj(e?.message), }); } duration(e) { return this._addCheck({ kind: `duration`, ...v.errToObj(e) }); } regex(e, t) { return this._addCheck({ kind: `regex`, regex: e, ...v.errToObj(t) }); } includes(e, t) { return this._addCheck({ kind: `includes`, value: e, position: t?.position, ...v.errToObj(t?.message), }); } startsWith(e, t) { return this._addCheck({ kind: `startsWith`, value: e, ...v.errToObj(t) }); } endsWith(e, t) { return this._addCheck({ kind: `endsWith`, value: e, ...v.errToObj(t) }); } min(e, t) { return this._addCheck({ kind: `min`, value: e, ...v.errToObj(t) }); } max(e, t) { return this._addCheck({ kind: `max`, value: e, ...v.errToObj(t) }); } length(e, t) { return this._addCheck({ kind: `length`, value: e, ...v.errToObj(t) }); } nonempty(e) { return this.min(1, v.errToObj(e)); } trim() { return new e({ ...this._def, checks: [...this._def.checks, { kind: `trim` }] }); } toLowerCase() { return new e({ ...this._def, checks: [...this._def.checks, { kind: `toLowerCase` }] }); } toUpperCase() { return new e({ ...this._def, checks: [...this._def.checks, { kind: `toUpperCase` }] }); } get isDatetime() { return !!this._def.checks.find((e) => e.kind === `datetime`); } get isDate() { return !!this._def.checks.find((e) => e.kind === `date`); } get isTime() { return !!this._def.checks.find((e) => e.kind === `time`); } get isDuration() { return !!this._def.checks.find((e) => e.kind === `duration`); } get isEmail() { return !!this._def.checks.find((e) => e.kind === `email`); } get isURL() { return !!this._def.checks.find((e) => e.kind === `url`); } get isEmoji() { return !!this._def.checks.find((e) => e.kind === `emoji`); } get isUUID() { return !!this._def.checks.find((e) => e.kind === `uuid`); } get isNANOID() { return !!this._def.checks.find((e) => e.kind === `nanoid`); } get isCUID() { return !!this._def.checks.find((e) => e.kind === `cuid`); } get isCUID2() { return !!this._def.checks.find((e) => e.kind === `cuid2`); } get isULID() { return !!this._def.checks.find((e) => e.kind === `ulid`); } get isIP() { return !!this._def.checks.find((e) => e.kind === `ip`); } get isCIDR() { return !!this._def.checks.find((e) => e.kind === `cidr`); } get isBase64() { return !!this._def.checks.find((e) => e.kind === `base64`); } get isBase64url() { return !!this._def.checks.find((e) => e.kind === `base64url`); } get minLength() { let e = null; for (let t of this._def.checks) t.kind === `min` && (e === null || t.value > e) && (e = t.value); return e; } get maxLength() { let e = null; for (let t of this._def.checks) t.kind === `max` && (e === null || t.value < e) && (e = t.value); return e; } }; S.create = (e) => new S({ checks: [], typeName: Q.ZodString, coerce: e?.coerce ?? !1, ...b(e) }); function Ae(e, t) { let n = (e.toString().split(`.`)[1] || ``).length, r = (t.toString().split(`.`)[1] || ``).length, i = n > r ? n : r; return ( (Number.parseInt(e.toFixed(i).replace(`.`, ``)) % Number.parseInt(t.toFixed(i).replace(`.`, ``))) / 10 ** i ); } var C = class e extends x { constructor() { (super(...arguments), (this.min = this.gte), (this.max = this.lte), (this.step = this.multipleOf)); } _parse(e) { if ((this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== i.number)) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.number, received: t.parsedType }), m); } let t, r = new p(); for (let i of this._def.checks) i.kind === `int` ? n.isInteger(e.data) || ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.invalid_type, expected: `integer`, received: `float`, message: i.message, }), r.dirty()) : i.kind === `min` ? (i.inclusive ? e.data < i.value : e.data <= i.value) && ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.too_small, minimum: i.value, type: `number`, inclusive: i.inclusive, exact: !1, message: i.message, }), r.dirty()) : i.kind === `max` ? (i.inclusive ? e.data > i.value : e.data >= i.value) && ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.too_big, maximum: i.value, type: `number`, inclusive: i.inclusive, exact: !1, message: i.message, }), r.dirty()) : i.kind === `multipleOf` ? Ae(e.data, i.value) !== 0 && ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.not_multiple_of, multipleOf: i.value, message: i.message }), r.dirty()) : i.kind === `finite` ? Number.isFinite(e.data) || ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.not_finite, message: i.message }), r.dirty()) : n.assertNever(i); return { status: r.value, value: e.data }; } gte(e, t) { return this.setLimit(`min`, e, !0, v.toString(t)); } gt(e, t) { return this.setLimit(`min`, e, !1, v.toString(t)); } lte(e, t) { return this.setLimit(`max`, e, !0, v.toString(t)); } lt(e, t) { return this.setLimit(`max`, e, !1, v.toString(t)); } setLimit(t, n, r, i) { return new e({ ...this._def, checks: [...this._def.checks, { kind: t, value: n, inclusive: r, message: v.toString(i) }], }); } _addCheck(t) { return new e({ ...this._def, checks: [...this._def.checks, t] }); } int(e) { return this._addCheck({ kind: `int`, message: v.toString(e) }); } positive(e) { return this._addCheck({ kind: `min`, value: 0, inclusive: !1, message: v.toString(e) }); } negative(e) { return this._addCheck({ kind: `max`, value: 0, inclusive: !1, message: v.toString(e) }); } nonpositive(e) { return this._addCheck({ kind: `max`, value: 0, inclusive: !0, message: v.toString(e) }); } nonnegative(e) { return this._addCheck({ kind: `min`, value: 0, inclusive: !0, message: v.toString(e) }); } multipleOf(e, t) { return this._addCheck({ kind: `multipleOf`, value: e, message: v.toString(t) }); } finite(e) { return this._addCheck({ kind: `finite`, message: v.toString(e) }); } safe(e) { return this._addCheck({ kind: `min`, inclusive: !0, value: -(2 ** 53 - 1), message: v.toString(e), })._addCheck({ kind: `max`, inclusive: !0, value: 2 ** 53 - 1, message: v.toString(e) }); } get minValue() { let e = null; for (let t of this._def.checks) t.kind === `min` && (e === null || t.value > e) && (e = t.value); return e; } get maxValue() { let e = null; for (let t of this._def.checks) t.kind === `max` && (e === null || t.value < e) && (e = t.value); return e; } get isInt() { return !!this._def.checks.find( (e) => e.kind === `int` || (e.kind === `multipleOf` && n.isInteger(e.value)), ); } get isFinite() { let e = null, t = null; for (let n of this._def.checks) if (n.kind === `finite` || n.kind === `int` || n.kind === `multipleOf`) return !0; else n.kind === `min` ? (t === null || n.value > t) && (t = n.value) : n.kind === `max` && (e === null || n.value < e) && (e = n.value); return Number.isFinite(t) && Number.isFinite(e); } }; C.create = (e) => new C({ checks: [], typeName: Q.ZodNumber, coerce: e?.coerce || !1, ...b(e) }); var w = class e extends x { constructor() { (super(...arguments), (this.min = this.gte), (this.max = this.lte)); } _parse(e) { if (this._def.coerce) try { e.data = BigInt(e.data); } catch { return this._getInvalidInput(e); } if (this._getType(e) !== i.bigint) return this._getInvalidInput(e); let t, r = new p(); for (let i of this._def.checks) i.kind === `min` ? (i.inclusive ? e.data < i.value : e.data <= i.value) && ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.too_small, type: `bigint`, minimum: i.value, inclusive: i.inclusive, message: i.message, }), r.dirty()) : i.kind === `max` ? (i.inclusive ? e.data > i.value : e.data >= i.value) && ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.too_big, type: `bigint`, maximum: i.value, inclusive: i.inclusive, message: i.message, }), r.dirty()) : i.kind === `multipleOf` ? e.data % i.value !== BigInt(0) && ((t = this._getOrReturnCtx(e, t)), f(t, { code: o.not_multiple_of, multipleOf: i.value, message: i.message }), r.dirty()) : n.assertNever(i); return { status: r.value, value: e.data }; } _getInvalidInput(e) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.bigint, received: t.parsedType }), m); } gte(e, t) { return this.setLimit(`min`, e, !0, v.toString(t)); } gt(e, t) { return this.setLimit(`min`, e, !1, v.toString(t)); } lte(e, t) { return this.setLimit(`max`, e, !0, v.toString(t)); } lt(e, t) { return this.setLimit(`max`, e, !1, v.toString(t)); } setLimit(t, n, r, i) { return new e({ ...this._def, checks: [...this._def.checks, { kind: t, value: n, inclusive: r, message: v.toString(i) }], }); } _addCheck(t) { return new e({ ...this._def, checks: [...this._def.checks, t] }); } positive(e) { return this._addCheck({ kind: `min`, value: BigInt(0), inclusive: !1, message: v.toString(e) }); } negative(e) { return this._addCheck({ kind: `max`, value: BigInt(0), inclusive: !1, message: v.toString(e) }); } nonpositive(e) { return this._addCheck({ kind: `max`, value: BigInt(0), inclusive: !0, message: v.toString(e) }); } nonnegative(e) { return this._addCheck({ kind: `min`, value: BigInt(0), inclusive: !0, message: v.toString(e) }); } multipleOf(e, t) { return this._addCheck({ kind: `multipleOf`, value: e, message: v.toString(t) }); } get minValue() { let e = null; for (let t of this._def.checks) t.kind === `min` && (e === null || t.value > e) && (e = t.value); return e; } get maxValue() { let e = null; for (let t of this._def.checks) t.kind === `max` && (e === null || t.value < e) && (e = t.value); return e; } }; w.create = (e) => new w({ checks: [], typeName: Q.ZodBigInt, coerce: e?.coerce ?? !1, ...b(e) }); var T = class extends x { _parse(e) { if ((this._def.coerce && (e.data = !!e.data), this._getType(e) !== i.boolean)) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.boolean, received: t.parsedType }), m); } return h(e.data); } }; T.create = (e) => new T({ typeName: Q.ZodBoolean, coerce: e?.coerce || !1, ...b(e) }); var E = class e extends x { _parse(e) { if ((this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== i.date)) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.date, received: t.parsedType }), m); } if (Number.isNaN(e.data.getTime())) return (f(this._getOrReturnCtx(e), { code: o.invalid_date }), m); let t = new p(), r; for (let i of this._def.checks) i.kind === `min` ? e.data.getTime() < i.value && ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.too_small, message: i.message, inclusive: !0, exact: !1, minimum: i.value, type: `date`, }), t.dirty()) : i.kind === `max` ? e.data.getTime() > i.value && ((r = this._getOrReturnCtx(e, r)), f(r, { code: o.too_big, message: i.message, inclusive: !0, exact: !1, maximum: i.value, type: `date`, }), t.dirty()) : n.assertNever(i); return { status: t.value, value: new Date(e.data.getTime()) }; } _addCheck(t) { return new e({ ...this._def, checks: [...this._def.checks, t] }); } min(e, t) { return this._addCheck({ kind: `min`, value: e.getTime(), message: v.toString(t) }); } max(e, t) { return this._addCheck({ kind: `max`, value: e.getTime(), message: v.toString(t) }); } get minDate() { let e = null; for (let t of this._def.checks) t.kind === `min` && (e === null || t.value > e) && (e = t.value); return e == null ? null : new Date(e); } get maxDate() { let e = null; for (let t of this._def.checks) t.kind === `max` && (e === null || t.value < e) && (e = t.value); return e == null ? null : new Date(e); } }; E.create = (e) => new E({ checks: [], coerce: e?.coerce || !1, typeName: Q.ZodDate, ...b(e) }); var D = class extends x { _parse(e) { if (this._getType(e) !== i.symbol) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.symbol, received: t.parsedType }), m); } return h(e.data); } }; D.create = (e) => new D({ typeName: Q.ZodSymbol, ...b(e) }); var O = class extends x { _parse(e) { if (this._getType(e) !== i.undefined) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.undefined, received: t.parsedType }), m); } return h(e.data); } }; O.create = (e) => new O({ typeName: Q.ZodUndefined, ...b(e) }); var k = class extends x { _parse(e) { if (this._getType(e) !== i.null) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.null, received: t.parsedType }), m); } return h(e.data); } }; k.create = (e) => new k({ typeName: Q.ZodNull, ...b(e) }); var A = class extends x { constructor() { (super(...arguments), (this._any = !0)); } _parse(e) { return h(e.data); } }; A.create = (e) => new A({ typeName: Q.ZodAny, ...b(e) }); var j = class extends x { constructor() { (super(...arguments), (this._unknown = !0)); } _parse(e) { return h(e.data); } }; j.create = (e) => new j({ typeName: Q.ZodUnknown, ...b(e) }); var M = class extends x { _parse(e) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.never, received: t.parsedType }), m); } }; M.create = (e) => new M({ typeName: Q.ZodNever, ...b(e) }); var N = class extends x { _parse(e) { if (this._getType(e) !== i.undefined) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.void, received: t.parsedType }), m); } return h(e.data); } }; N.create = (e) => new N({ typeName: Q.ZodVoid, ...b(e) }); var P = class e extends x { _parse(e) { let { ctx: t, status: n } = this._processInputParams(e), r = this._def; if (t.parsedType !== i.array) return (f(t, { code: o.invalid_type, expected: i.array, received: t.parsedType }), m); if (r.exactLength !== null) { let e = t.data.length > r.exactLength.value, i = t.data.length < r.exactLength.value; (e || i) && (f(t, { code: e ? o.too_big : o.too_small, minimum: i ? r.exactLength.value : void 0, maximum: e ? r.exactLength.value : void 0, type: `array`, inclusive: !0, exact: !0, message: r.exactLength.message, }), n.dirty()); } if ( (r.minLength !== null && t.data.length < r.minLength.value && (f(t, { code: o.too_small, minimum: r.minLength.value, type: `array`, inclusive: !0, exact: !1, message: r.minLength.message, }), n.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (f(t, { code: o.too_big, maximum: r.maxLength.value, type: `array`, inclusive: !0, exact: !1, message: r.maxLength.message, }), n.dirty()), t.common.async) ) return Promise.all( [...t.data].map((e, n) => r.type._parseAsync(new y(t, e, t.path, n))), ).then((e) => p.mergeArray(n, e)); let a = [...t.data].map((e, n) => r.type._parseSync(new y(t, e, t.path, n))); return p.mergeArray(n, a); } get element() { return this._def.type; } min(t, n) { return new e({ ...this._def, minLength: { value: t, message: v.toString(n) } }); } max(t, n) { return new e({ ...this._def, maxLength: { value: t, message: v.toString(n) } }); } length(t, n) { return new e({ ...this._def, exactLength: { value: t, message: v.toString(n) } }); } nonempty(e) { return this.min(1, e); } }; P.create = (e, t) => new P({ type: e, minLength: null, maxLength: null, exactLength: null, typeName: Q.ZodArray, ...b(t), }); function F(e) { if (e instanceof I) { let t = {}; for (let n in e.shape) { let r = e.shape[n]; t[n] = q.create(F(r)); } return new I({ ...e._def, shape: () => t }); } else if (e instanceof P) return new P({ ...e._def, type: F(e.element) }); else if (e instanceof q) return q.create(F(e.unwrap())); else if (e instanceof J) return J.create(F(e.unwrap())); else if (e instanceof B) return B.create(e.items.map((e) => F(e))); else return e; } var I = class e extends x { constructor() { (super(...arguments), (this._cached = null), (this.nonstrict = this.passthrough), (this.augment = this.extend)); } _getCached() { if (this._cached !== null) return this._cached; let e = this._def.shape(), t = n.objectKeys(e); return ((this._cached = { shape: e, keys: t }), this._cached); } _parse(e) { if (this._getType(e) !== i.object) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.object, received: t.parsedType }), m); } let { status: t, ctx: n } = this._processInputParams(e), { shape: r, keys: a } = this._getCached(), s = []; if (!(this._def.catchall instanceof M && this._def.unknownKeys === `strip`)) for (let e in n.data) a.includes(e) || s.push(e); let c = []; for (let e of a) { let t = r[e], i = n.data[e]; c.push({ key: { status: `valid`, value: e }, value: t._parse(new y(n, i, n.path, e)), alwaysSet: e in n.data, }); } if (this._def.catchall instanceof M) { let e = this._def.unknownKeys; if (e === `passthrough`) for (let e of s) c.push({ key: { status: `valid`, value: e }, value: { status: `valid`, value: n.data[e] }, }); else if (e === `strict`) s.length > 0 && (f(n, { code: o.unrecognized_keys, keys: s }), t.dirty()); else if (e !== `strip`) throw Error(`Internal ZodObject error: invalid unknownKeys value.`); } else { let e = this._def.catchall; for (let t of s) { let r = n.data[t]; c.push({ key: { status: `valid`, value: t }, value: e._parse(new y(n, r, n.path, t)), alwaysSet: t in n.data, }); } } return n.common.async ? Promise.resolve() .then(async () => { let e = []; for (let t of c) { let n = await t.key, r = await t.value; e.push({ key: n, value: r, alwaysSet: t.alwaysSet }); } return e; }) .then((e) => p.mergeObjectSync(t, e)) : p.mergeObjectSync(t, c); } get shape() { return this._def.shape(); } strict(t) { return ( v.errToObj, new e({ ...this._def, unknownKeys: `strict`, ...(t === void 0 ? {} : { errorMap: (e, n) => { let r = this._def.errorMap?.(e, n).message ?? n.defaultError; return e.code === `unrecognized_keys` ? { message: v.errToObj(t).message ?? r } : { message: r }; }, }), }) ); } strip() { return new e({ ...this._def, unknownKeys: `strip` }); } passthrough() { return new e({ ...this._def, unknownKeys: `passthrough` }); } extend(t) { return new e({ ...this._def, shape: () => ({ ...this._def.shape(), ...t }) }); } merge(t) { return new e({ unknownKeys: t._def.unknownKeys, catchall: t._def.catchall, shape: () => ({ ...this._def.shape(), ...t._def.shape() }), typeName: Q.ZodObject, }); } setKey(e, t) { return this.augment({ [e]: t }); } catchall(t) { return new e({ ...this._def, catchall: t }); } pick(t) { let r = {}; for (let e of n.objectKeys(t)) t[e] && this.shape[e] && (r[e] = this.shape[e]); return new e({ ...this._def, shape: () => r }); } omit(t) { let r = {}; for (let e of n.objectKeys(this.shape)) t[e] || (r[e] = this.shape[e]); return new e({ ...this._def, shape: () => r }); } deepPartial() { return F(this); } partial(t) { let r = {}; for (let e of n.objectKeys(this.shape)) { let n = this.shape[e]; t && !t[e] ? (r[e] = n) : (r[e] = n.optional()); } return new e({ ...this._def, shape: () => r }); } required(t) { let r = {}; for (let e of n.objectKeys(this.shape)) if (t && !t[e]) r[e] = this.shape[e]; else { let t = this.shape[e]; for (; t instanceof q;) t = t._def.innerType; r[e] = t; } return new e({ ...this._def, shape: () => r }); } keyof() { return Le(n.objectKeys(this.shape)); } }; ((I.create = (e, t) => new I({ shape: () => e, unknownKeys: `strip`, catchall: M.create(), typeName: Q.ZodObject, ...b(t), })), (I.strictCreate = (e, t) => new I({ shape: () => e, unknownKeys: `strict`, catchall: M.create(), typeName: Q.ZodObject, ...b(t), })), (I.lazycreate = (e, t) => new I({ shape: e, unknownKeys: `strip`, catchall: M.create(), typeName: Q.ZodObject, ...b(t), }))); var L = class extends x { _parse(e) { let { ctx: t } = this._processInputParams(e), n = this._def.options; function r(e) { for (let t of e) if (t.result.status === `valid`) return t.result; for (let n of e) if (n.result.status === `dirty`) return (t.common.issues.push(...n.ctx.common.issues), n.result); let n = e.map((e) => new c(e.ctx.common.issues)); return (f(t, { code: o.invalid_union, unionErrors: n }), m); } if (t.common.async) return Promise.all( n.map(async (e) => { let n = { ...t, common: { ...t.common, issues: [] }, parent: null }; return { result: await e._parseAsync({ data: t.data, path: t.path, parent: n }), ctx: n }; }), ).then(r); { let e, r = []; for (let i of n) { let n = { ...t, common: { ...t.common, issues: [] }, parent: null }, a = i._parseSync({ data: t.data, path: t.path, parent: n }); if (a.status === `valid`) return a; (a.status === `dirty` && !e && (e = { result: a, ctx: n }), n.common.issues.length && r.push(n.common.issues)); } if (e) return (t.common.issues.push(...e.ctx.common.issues), e.result); let i = r.map((e) => new c(e)); return (f(t, { code: o.invalid_union, unionErrors: i }), m); } } get options() { return this._def.options; } }; L.create = (e, t) => new L({ options: e, typeName: Q.ZodUnion, ...b(t) }); const R = (e) => e instanceof V ? R(e.schema) : e instanceof K ? R(e.innerType()) : e instanceof H ? [e.value] : e instanceof U ? e.options : e instanceof W ? n.objectValues(e.enum) : e instanceof Y ? R(e._def.innerType) : e instanceof O ? [void 0] : e instanceof k ? [null] : e instanceof q ? [void 0, ...R(e.unwrap())] : e instanceof J ? [null, ...R(e.unwrap())] : e instanceof Be || e instanceof Z ? R(e.unwrap()) : e instanceof X ? R(e._def.innerType) : []; var je = class e extends x { _parse(e) { let { ctx: t } = this._processInputParams(e); if (t.parsedType !== i.object) return (f(t, { code: o.invalid_type, expected: i.object, received: t.parsedType }), m); let n = this.discriminator, r = t.data[n], a = this.optionsMap.get(r); return a ? t.common.async ? a._parseAsync({ data: t.data, path: t.path, parent: t }) : a._parseSync({ data: t.data, path: t.path, parent: t }) : (f(t, { code: o.invalid_union_discriminator, options: Array.from(this.optionsMap.keys()), path: [n], }), m); } get discriminator() { return this._def.discriminator; } get options() { return this._def.options; } get optionsMap() { return this._def.optionsMap; } static create(t, n, r) { let i = new Map(); for (let e of n) { let n = R(e.shape[t]); if (!n.length) throw Error( `A discriminator value for key \`${t}\` could not be extracted from all schema options`, ); for (let r of n) { if (i.has(r)) throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`); i.set(r, e); } } return new e({ typeName: Q.ZodDiscriminatedUnion, discriminator: t, options: n, optionsMap: i, ...b(r), }); } }; function Me(e, t) { let r = a(e), o = a(t); if (e === t) return { valid: !0, data: e }; if (r === i.object && o === i.object) { let r = n.objectKeys(t), i = n.objectKeys(e).filter((e) => r.indexOf(e) !== -1), a = { ...e, ...t }; for (let n of i) { let r = Me(e[n], t[n]); if (!r.valid) return { valid: !1 }; a[n] = r.data; } return { valid: !0, data: a }; } else if (r === i.array && o === i.array) { if (e.length !== t.length) return { valid: !1 }; let n = []; for (let r = 0; r < e.length; r++) { let i = e[r], a = t[r], o = Me(i, a); if (!o.valid) return { valid: !1 }; n.push(o.data); } return { valid: !0, data: n }; } else if (r === i.date && o === i.date && +e == +t) return { valid: !0, data: e }; else return { valid: !1 }; } var z = class extends x { _parse(e) { let { status: t, ctx: n } = this._processInputParams(e), r = (e, r) => { if (ie(e) || ie(r)) return m; let i = Me(e.value, r.value); return i.valid ? ((ae(e) || ae(r)) && t.dirty(), { status: t.value, value: i.data }) : (f(n, { code: o.invalid_intersection_types }), m); }; return n.common.async ? Promise.all([ this._def.left._parseAsync({ data: n.data, path: n.path, parent: n }), this._def.right._parseAsync({ data: n.data, path: n.path, parent: n }), ]).then(([e, t]) => r(e, t)) : r( this._def.left._parseSync({ data: n.data, path: n.path, parent: n }), this._def.right._parseSync({ data: n.data, path: n.path, parent: n }), ); } }; z.create = (e, t, n) => new z({ left: e, right: t, typeName: Q.ZodIntersection, ...b(n) }); var B = class e extends x { _parse(e) { let { status: t, ctx: n } = this._processInputParams(e); if (n.parsedType !== i.array) return (f(n, { code: o.invalid_type, expected: i.array, received: n.parsedType }), m); if (n.data.length < this._def.items.length) return ( f(n, { code: o.too_small, minimum: this._def.items.length, inclusive: !0, exact: !1, type: `array`, }), m ); !this._def.rest && n.data.length > this._def.items.length && (f(n, { code: o.too_big, maximum: this._def.items.length, inclusive: !0, exact: !1, type: `array`, }), t.dirty()); let r = [...n.data] .map((e, t) => { let r = this._def.items[t] || this._def.rest; return r ? r._parse(new y(n, e, n.path, t)) : null; }) .filter((e) => !!e); return n.common.async ? Promise.all(r).then((e) => p.mergeArray(t, e)) : p.mergeArray(t, r); } get items() { return this._def.items; } rest(t) { return new e({ ...this._def, rest: t }); } }; B.create = (e, t) => { if (!Array.isArray(e)) throw Error(`You must pass an array of schemas to z.tuple([ ... ])`); return new B({ items: e, typeName: Q.ZodTuple, rest: null, ...b(t) }); }; var Ne = class e extends x { get keySchema() { return this._def.keyType; } get valueSchema() { return this._def.valueType; } _parse(e) { let { status: t, ctx: n } = this._processInputParams(e); if (n.parsedType !== i.object) return (f(n, { code: o.invalid_type, expected: i.object, received: n.parsedType }), m); let r = [], a = this._def.keyType, s = this._def.valueType; for (let e in n.data) r.push({ key: a._parse(new y(n, e, n.path, e)), value: s._parse(new y(n, n.data[e], n.path, e)), alwaysSet: e in n.data, }); return n.common.async ? p.mergeObjectAsync(t, r) : p.mergeObjectSync(t, r); } get element() { return this._def.valueType; } static create(t, n, r) { return n instanceof x ? new e({ keyType: t, valueType: n, typeName: Q.ZodRecord, ...b(r) }) : new e({ keyType: S.create(), valueType: t, typeName: Q.ZodRecord, ...b(n) }); } }, Pe = class extends x { get keySchema() { return this._def.keyType; } get valueSchema() { return this._def.valueType; } _parse(e) { let { status: t, ctx: n } = this._processInputParams(e); if (n.parsedType !== i.map) return (f(n, { code: o.invalid_type, expected: i.map, received: n.parsedType }), m); let r = this._def.keyType, a = this._def.valueType, s = [...n.data.entries()].map(([e, t], i) => ({ key: r._parse(new y(n, e, n.path, [i, `key`])), value: a._parse(new y(n, t, n.path, [i, `value`])), })); if (n.common.async) { let e = new Map(); return Promise.resolve().then(async () => { for (let n of s) { let r = await n.key, i = await n.value; if (r.status === `aborted` || i.status === `aborted`) return m; ((r.status === `dirty` || i.status === `dirty`) && t.dirty(), e.set(r.value, i.value)); } return { status: t.value, value: e }; }); } else { let e = new Map(); for (let n of s) { let r = n.key, i = n.value; if (r.status === `aborted` || i.status === `aborted`) return m; ((r.status === `dirty` || i.status === `dirty`) && t.dirty(), e.set(r.value, i.value)); } return { status: t.value, value: e }; } } }; Pe.create = (e, t, n) => new Pe({ valueType: t, keyType: e, typeName: Q.ZodMap, ...b(n) }); var Fe = class e extends x { _parse(e) { let { status: t, ctx: n } = this._processInputParams(e); if (n.parsedType !== i.set) return (f(n, { code: o.invalid_type, expected: i.set, received: n.parsedType }), m); let r = this._def; (r.minSize !== null && n.data.size < r.minSize.value && (f(n, { code: o.too_small, minimum: r.minSize.value, type: `set`, inclusive: !0, exact: !1, message: r.minSize.message, }), t.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (f(n, { code: o.too_big, maximum: r.maxSize.value, type: `set`, inclusive: !0, exact: !1, message: r.maxSize.message, }), t.dirty())); let a = this._def.valueType; function s(e) { let n = new Set(); for (let r of e) { if (r.status === `aborted`) return m; (r.status === `dirty` && t.dirty(), n.add(r.value)); } return { status: t.value, value: n }; } let c = [...n.data.values()].map((e, t) => a._parse(new y(n, e, n.path, t))); return n.common.async ? Promise.all(c).then((e) => s(e)) : s(c); } min(t, n) { return new e({ ...this._def, minSize: { value: t, message: v.toString(n) } }); } max(t, n) { return new e({ ...this._def, maxSize: { value: t, message: v.toString(n) } }); } size(e, t) { return this.min(e, t).max(e, t); } nonempty(e) { return this.min(1, e); } }; Fe.create = (e, t) => new Fe({ valueType: e, minSize: null, maxSize: null, typeName: Q.ZodSet, ...b(t) }); var Ie = class e extends x { constructor() { (super(...arguments), (this.validate = this.implement)); } _parse(e) { let { ctx: t } = this._processInputParams(e); if (t.parsedType !== i.function) return (f(t, { code: o.invalid_type, expected: i.function, received: t.parsedType }), m); function n(e, n) { return d({ data: e, path: t.path, errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, u(), l].filter((e) => !!e), issueData: { code: o.invalid_arguments, argumentsError: n }, }); } function r(e, n) { return d({ data: e, path: t.path, errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, u(), l].filter((e) => !!e), issueData: { code: o.invalid_return_type, returnTypeError: n }, }); } let a = { errorMap: t.common.contextualErrorMap }, s = t.data; if (this._def.returns instanceof G) { let e = this; return h(async function (...t) { let i = new c([]), o = await e._def.args.parseAsync(t, a).catch((e) => { throw (i.addIssue(n(t, e)), i); }), l = await Reflect.apply(s, this, o); return await e._def.returns._def.type.parseAsync(l, a).catch((e) => { throw (i.addIssue(r(l, e)), i); }); }); } else { let e = this; return h(function (...t) { let i = e._def.args.safeParse(t, a); if (!i.success) throw new c([n(t, i.error)]); let o = Reflect.apply(s, this, i.data), l = e._def.returns.safeParse(o, a); if (!l.success) throw new c([r(o, l.error)]); return l.data; }); } } parameters() { return this._def.args; } returnType() { return this._def.returns; } args(...t) { return new e({ ...this._def, args: B.create(t).rest(j.create()) }); } returns(t) { return new e({ ...this._def, returns: t }); } implement(e) { return this.parse(e); } strictImplement(e) { return this.parse(e); } static create(t, n, r) { return new e({ args: t || B.create([]).rest(j.create()), returns: n || j.create(), typeName: Q.ZodFunction, ...b(r), }); } }, V = class extends x { get schema() { return this._def.getter(); } _parse(e) { let { ctx: t } = this._processInputParams(e); return this._def.getter()._parse({ data: t.data, path: t.path, parent: t }); } }; V.create = (e, t) => new V({ getter: e, typeName: Q.ZodLazy, ...b(t) }); var H = class extends x { _parse(e) { if (e.data !== this._def.value) { let t = this._getOrReturnCtx(e); return (f(t, { received: t.data, code: o.invalid_literal, expected: this._def.value }), m); } return { status: `valid`, value: e.data }; } get value() { return this._def.value; } }; H.create = (e, t) => new H({ value: e, typeName: Q.ZodLiteral, ...b(t) }); function Le(e, t) { return new U({ values: e, typeName: Q.ZodEnum, ...b(t) }); } var U = class e extends x { _parse(e) { if (typeof e.data != `string`) { let t = this._getOrReturnCtx(e), r = this._def.values; return (f(t, { expected: n.joinValues(r), received: t.parsedType, code: o.invalid_type }), m); } if (((this._cache ||= new Set(this._def.values)), !this._cache.has(e.data))) { let t = this._getOrReturnCtx(e), n = this._def.values; return (f(t, { received: t.data, code: o.invalid_enum_value, options: n }), m); } return h(e.data); } get options() { return this._def.values; } get enum() { let e = {}; for (let t of this._def.values) e[t] = t; return e; } get Values() { let e = {}; for (let t of this._def.values) e[t] = t; return e; } get Enum() { let e = {}; for (let t of this._def.values) e[t] = t; return e; } extract(t, n = this._def) { return e.create(t, { ...this._def, ...n }); } exclude(t, n = this._def) { return e.create( this.options.filter((e) => !t.includes(e)), { ...this._def, ...n }, ); } }; U.create = Le; var W = class extends x { _parse(e) { let t = n.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e); if (r.parsedType !== i.string && r.parsedType !== i.number) { let e = n.objectValues(t); return (f(r, { expected: n.joinValues(e), received: r.parsedType, code: o.invalid_type }), m); } if ( ((this._cache ||= new Set(n.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) ) { let e = n.objectValues(t); return (f(r, { received: r.data, code: o.invalid_enum_value, options: e }), m); } return h(e.data); } get enum() { return this._def.values; } }; W.create = (e, t) => new W({ values: e, typeName: Q.ZodNativeEnum, ...b(t) }); var G = class extends x { unwrap() { return this._def.type; } _parse(e) { let { ctx: t } = this._processInputParams(e); return t.parsedType !== i.promise && t.common.async === !1 ? (f(t, { code: o.invalid_type, expected: i.promise, received: t.parsedType }), m) : h( (t.parsedType === i.promise ? t.data : Promise.resolve(t.data)).then((e) => this._def.type.parseAsync(e, { path: t.path, errorMap: t.common.contextualErrorMap }), ), ); } }; G.create = (e, t) => new G({ type: e, typeName: Q.ZodPromise, ...b(t) }); var K = class extends x { innerType() { return this._def.schema; } sourceType() { return this._def.schema._def.typeName === Q.ZodEffects ? this._def.schema.sourceType() : this._def.schema; } _parse(e) { let { status: t, ctx: r } = this._processInputParams(e), i = this._def.effect || null, a = { addIssue: (e) => { (f(r, e), e.fatal ? t.abort() : t.dirty()); }, get path() { return r.path; }, }; if (((a.addIssue = a.addIssue.bind(a)), i.type === `preprocess`)) { let e = i.transform(r.data, a); if (r.common.async) return Promise.resolve(e).then(async (e) => { if (t.value === `aborted`) return m; let n = await this._def.schema._parseAsync({ data: e, path: r.path, parent: r }); return n.status === `aborted` ? m : n.status === `dirty` || t.value === `dirty` ? re(n.value) : n; }); { if (t.value === `aborted`) return m; let n = this._def.schema._parseSync({ data: e, path: r.path, parent: r }); return n.status === `aborted` ? m : n.status === `dirty` || t.value === `dirty` ? re(n.value) : n; } } if (i.type === `refinement`) { let e = (e) => { let t = i.refinement(e, a); if (r.common.async) return Promise.resolve(t); if (t instanceof Promise) throw Error( `Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`, ); return e; }; if (r.common.async === !1) { let n = this._def.schema._parseSync({ data: r.data, path: r.path, parent: r }); return n.status === `aborted` ? m : (n.status === `dirty` && t.dirty(), e(n.value), { status: t.value, value: n.value }); } else return this._def.schema ._parseAsync({ data: r.data, path: r.path, parent: r }) .then((n) => n.status === `aborted` ? m : (n.status === `dirty` && t.dirty(), e(n.value).then(() => ({ status: t.value, value: n.value }))), ); } if (i.type === `transform`) if (r.common.async === !1) { let e = this._def.schema._parseSync({ data: r.data, path: r.path, parent: r }); if (!g(e)) return m; let n = i.transform(e.value, a); if (n instanceof Promise) throw Error( `Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`, ); return { status: t.value, value: n }; } else return this._def.schema ._parseAsync({ data: r.data, path: r.path, parent: r }) .then((e) => g(e) ? Promise.resolve(i.transform(e.value, a)).then((e) => ({ status: t.value, value: e, })) : m, ); n.assertNever(i); } }; ((K.create = (e, t, n) => new K({ schema: e, typeName: Q.ZodEffects, effect: t, ...b(n) })), (K.createWithPreprocess = (e, t, n) => new K({ schema: t, effect: { type: `preprocess`, transform: e }, typeName: Q.ZodEffects, ...b(n), }))); var q = class extends x { _parse(e) { return this._getType(e) === i.undefined ? h(void 0) : this._def.innerType._parse(e); } unwrap() { return this._def.innerType; } }; q.create = (e, t) => new q({ innerType: e, typeName: Q.ZodOptional, ...b(t) }); var J = class extends x { _parse(e) { return this._getType(e) === i.null ? h(null) : this._def.innerType._parse(e); } unwrap() { return this._def.innerType; } }; J.create = (e, t) => new J({ innerType: e, typeName: Q.ZodNullable, ...b(t) }); var Y = class extends x { _parse(e) { let { ctx: t } = this._processInputParams(e), n = t.data; return ( t.parsedType === i.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({ data: n, path: t.path, parent: t }) ); } removeDefault() { return this._def.innerType; } }; Y.create = (e, t) => new Y({ innerType: e, typeName: Q.ZodDefault, defaultValue: typeof t.default == `function` ? t.default : () => t.default, ...b(t), }); var X = class extends x { _parse(e) { let { ctx: t } = this._processInputParams(e), n = { ...t, common: { ...t.common, issues: [] } }, r = this._def.innerType._parse({ data: n.data, path: n.path, parent: { ...n } }); return _(r) ? r.then((e) => ({ status: `valid`, value: e.status === `valid` ? e.value : this._def.catchValue({ get error() { return new c(n.common.issues); }, input: n.data, }), })) : { status: `valid`, value: r.status === `valid` ? r.value : this._def.catchValue({ get error() { return new c(n.common.issues); }, input: n.data, }), }; } removeCatch() { return this._def.innerType; } }; X.create = (e, t) => new X({ innerType: e, typeName: Q.ZodCatch, catchValue: typeof t.catch == `function` ? t.catch : () => t.catch, ...b(t), }); var Re = class extends x { _parse(e) { if (this._getType(e) !== i.nan) { let t = this._getOrReturnCtx(e); return (f(t, { code: o.invalid_type, expected: i.nan, received: t.parsedType }), m); } return { status: `valid`, value: e.data }; } }; Re.create = (e) => new Re({ typeName: Q.ZodNaN, ...b(e) }); const ze = Symbol(`zod_brand`); var Be = class extends x { _parse(e) { let { ctx: t } = this._processInputParams(e), n = t.data; return this._def.type._parse({ data: n, path: t.path, parent: t }); } unwrap() { return this._def.type; } }, Ve = class e extends x { _parse(e) { let { status: t, ctx: n } = this._processInputParams(e); if (n.common.async) return (async () => { let e = await this._def.in._parseAsync({ data: n.data, path: n.path, parent: n }); return e.status === `aborted` ? m : e.status === `dirty` ? (t.dirty(), re(e.value)) : this._def.out._parseAsync({ data: e.value, path: n.path, parent: n }); })(); { let e = this._def.in._parseSync({ data: n.data, path: n.path, parent: n }); return e.status === `aborted` ? m : e.status === `dirty` ? (t.dirty(), { status: `dirty`, value: e.value }) : this._def.out._parseSync({ data: e.value, path: n.path, parent: n }); } } static create(t, n) { return new e({ in: t, out: n, typeName: Q.ZodPipeline }); } }, Z = class extends x { _parse(e) { let t = this._def.innerType._parse(e), n = (e) => (g(e) && (e.value = Object.freeze(e.value)), e); return _(t) ? t.then((e) => n(e)) : n(t); } unwrap() { return this._def.innerType; } }; Z.create = (e, t) => new Z({ innerType: e, typeName: Q.ZodReadonly, ...b(t) }); function He(e, t) { let n = typeof e == `function` ? e(t) : typeof e == `string` ? { message: e } : e; return typeof n == `string` ? { message: n } : n; } function Ue(e, t = {}, n) { return e ? A.create().superRefine((r, i) => { let a = e(r); if (a instanceof Promise) return a.then((e) => { if (!e) { let e = He(t, r), a = e.fatal ?? n ?? !0; i.addIssue({ code: `custom`, ...e, fatal: a }); } }); if (!a) { let e = He(t, r), a = e.fatal ?? n ?? !0; i.addIssue({ code: `custom`, ...e, fatal: a }); } }) : A.create(); } const We = { object: I.lazycreate }; var Q; (function (e) { ((e.ZodString = `ZodString`), (e.ZodNumber = `ZodNumber`), (e.ZodNaN = `ZodNaN`), (e.ZodBigInt = `ZodBigInt`), (e.ZodBoolean = `ZodBoolean`), (e.ZodDate = `ZodDate`), (e.ZodSymbol = `ZodSymbol`), (e.ZodUndefined = `ZodUndefined`), (e.ZodNull = `ZodNull`), (e.ZodAny = `ZodAny`), (e.ZodUnknown = `ZodUnknown`), (e.ZodNever = `ZodNever`), (e.ZodVoid = `ZodVoid`), (e.ZodArray = `ZodArray`), (e.ZodObject = `ZodObject`), (e.ZodUnion = `ZodUnion`), (e.ZodDiscriminatedUnion = `ZodDiscriminatedUnion`), (e.ZodIntersection = `ZodIntersection`), (e.ZodTuple = `ZodTuple`), (e.ZodRecord = `ZodRecord`), (e.ZodMap = `ZodMap`), (e.ZodSet = `ZodSet`), (e.ZodFunction = `ZodFunction`), (e.ZodLazy = `ZodLazy`), (e.ZodLiteral = `ZodLiteral`), (e.ZodEnum = `ZodEnum`), (e.ZodEffects = `ZodEffects`), (e.ZodNativeEnum = `ZodNativeEnum`), (e.ZodOptional = `ZodOptional`), (e.ZodNullable = `ZodNullable`), (e.ZodDefault = `ZodDefault`), (e.ZodCatch = `ZodCatch`), (e.ZodPromise = `ZodPromise`), (e.ZodBranded = `ZodBranded`), (e.ZodPipeline = `ZodPipeline`), (e.ZodReadonly = `ZodReadonly`)); })((Q ||= {})); const Ge = (e, t = { message: `Input not instance of ${e.name}` }) => Ue((t) => t instanceof e, t), Ke = S.create, qe = C.create, Je = Re.create, Ye = w.create, Xe = T.create, Ze = E.create, Qe = D.create, $e = O.create, et = k.create, tt = A.create, nt = j.create, rt = M.create, it = N.create, at = P.create, ot = I.create, st = I.strictCreate, ct = L.create, lt = je.create, ut = z.create, dt = B.create, ft = Ne.create, pt = Pe.create, mt = Fe.create, ht = Ie.create, gt = V.create, _t = H.create, vt = U.create, yt = W.create, bt = G.create, xt = K.create, St = q.create, Ct = J.create, wt = K.createWithPreprocess, Tt = Ve.create, Et = () => Ke().optional(), Dt = () => qe().optional(), Ot = () => Xe().optional(), kt = { string: (e) => S.create({ ...e, coerce: !0 }), number: (e) => C.create({ ...e, coerce: !0 }), boolean: (e) => T.create({ ...e, coerce: !0 }), bigint: (e) => w.create({ ...e, coerce: !0 }), date: (e) => E.create({ ...e, coerce: !0 }), }, At = m; var $ = t({ BRAND: () => ze, DIRTY: () => re, EMPTY_PATH: () => ne, INVALID: () => m, NEVER: () => At, OK: () => h, ParseStatus: () => p, Schema: () => x, ZodAny: () => A, ZodArray: () => P, ZodBigInt: () => w, ZodBoolean: () => T, ZodBranded: () => Be, ZodCatch: () => X, ZodDate: () => E, ZodDefault: () => Y, ZodDiscriminatedUnion: () => je, ZodEffects: () => K, ZodEnum: () => U, ZodError: () => c, ZodFirstPartyTypeKind: () => Q, ZodFunction: () => Ie, ZodIntersection: () => z, ZodIssueCode: () => o, ZodLazy: () => V, ZodLiteral: () => H, ZodMap: () => Pe, ZodNaN: () => Re, ZodNativeEnum: () => W, ZodNever: () => M, ZodNull: () => k, ZodNullable: () => J, ZodNumber: () => C, ZodObject: () => I, ZodOptional: () => q, ZodParsedType: () => i, ZodPipeline: () => Ve, ZodPromise: () => G, ZodReadonly: () => Z, ZodRecord: () => Ne, ZodSchema: () => x, ZodSet: () => Fe, ZodString: () => S, ZodSymbol: () => D, ZodTransformer: () => K, ZodTuple: () => B, ZodType: () => x, ZodUndefined: () => O, ZodUnion: () => L, ZodUnknown: () => j, ZodVoid: () => N, addIssueToContext: () => f, any: () => tt, array: () => at, bigint: () => Ye, boolean: () => Xe, coerce: () => kt, custom: () => Ue, date: () => Ze, datetimeRegex: () => Ee, defaultErrorMap: () => l, discriminatedUnion: () => lt, effect: () => xt, enum: () => vt, function: () => ht, getErrorMap: () => u, getParsedType: () => a, instanceof: () => Ge, intersection: () => ut, isAborted: () => ie, isAsync: () => _, isDirty: () => ae, isValid: () => g, late: () => We, lazy: () => gt, literal: () => _t, makeIssue: () => d, map: () => pt, nan: () => Je, nativeEnum: () => yt, never: () => rt, null: () => et, nullable: () => Ct, number: () => qe, object: () => ot, objectUtil: () => r, oboolean: () => Ot, onumber: () => Dt, optional: () => St, ostring: () => Et, pipeline: () => Tt, preprocess: () => wt, promise: () => bt, quotelessJson: () => s, record: () => ft, set: () => mt, setErrorMap: () => te, strictObject: () => st, string: () => Ke, symbol: () => Qe, transformer: () => xt, tuple: () => dt, undefined: () => $e, union: () => ct, unknown: () => nt, util: () => n, void: () => it, }); const jt = $.object({ id: $.number(), created: $.date(), title: $.string().min(1).max(100), type: $.enum([`jpg`, `png`]), size: $.number(), url: $.string().url(), }), Mt = $.object({ id: $.number(), stars: $.number().min(0).max(5), title: $.string().min(1).max(100), text: $.string().min(1).max(1e3), images: $.array(jt), }); $.object({ id: $.number(), created: $.date(), title: $.string().min(1).max(100), brand: $.string().min(1).max(30), description: $.string().min(1).max(500), price: $.number().min(1).max(1e4), discount: $.number().min(1).max(100).nullable(), quantity: $.number().min(0).max(10), tags: $.array($.string().min(1).max(30)), images: $.array(jt), ratings: $.array(Mt), }).parse({});
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures