LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

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

    • error
      Stack

    • article
      Blog
Expand sidebarExpand sidebar
zod/mini/Compiled (unminified)Compiled (unminified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/zod/mini/download_compiled/unminified.js
Copy to clipboardCopy to clipboard
Object.freeze({ status: "aborted" }); function $constructor(name, initializer, params) { function init(inst, def) { if (!inst._zod) Object.defineProperty(inst, "_zod", { value: { def, constr: _, traits: /* @__PURE__ */ new Set() }, enumerable: false }); if (inst._zod.traits.has(name)) return; inst._zod.traits.add(name); initializer(inst, def); const proto = _.prototype; const keys = Object.keys(proto); for (let i = 0; i < keys.length; i++) { const k = keys[i]; if (!(k in inst)) inst[k] = proto[k].bind(inst); } } const Parent = params?.Parent ?? Object; class Definition extends Parent {} Object.defineProperty(Definition, "name", { value: name }); function _(def) { var _a; const inst = params?.Parent ? new Definition() : this; init(inst, def); (_a = inst._zod).deferred ?? (_a.deferred = []); for (const fn of inst._zod.deferred) fn(); return inst; } Object.defineProperty(_, "init", { value: init }); Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => { if (params?.Parent && inst instanceof params.Parent) return true; return inst?._zod?.traits?.has(name); } }); Object.defineProperty(_, "name", { value: name }); return _; } var $ZodAsyncError = class extends Error { constructor() { super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`); } }; const globalConfig = {}; function config(newConfig) { if (newConfig) Object.assign(globalConfig, newConfig); return globalConfig; } //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js function getEnumValues(entries) { const numericValues = Object.values(entries).filter((v) => typeof v === "number"); return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v); } function jsonStringifyReplacer(_, value) { if (typeof value === "bigint") return value.toString(); return value; } function cached(getter) { return { get value() { { const value = getter(); Object.defineProperty(this, "value", { value }); return value; } throw new Error("cached value already set"); } }; } function nullish(input) { return input === null || input === void 0; } function cleanRegex(source) { const start = source.startsWith("^") ? 1 : 0; const end = source.endsWith("$") ? source.length - 1 : source.length; return source.slice(start, end); } const EVALUATING = Symbol("evaluating"); function defineLazy(object, key, getter) { let value = void 0; Object.defineProperty(object, key, { get() { if (value === EVALUATING) return; if (value === void 0) { value = EVALUATING; value = getter(); } return value; }, set(v) { Object.defineProperty(object, key, { value: v }); }, configurable: true }); } const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {}; function isObject(data) { return typeof data === "object" && data !== null && !Array.isArray(data); } cached(() => { if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false; try { new Function(""); return true; } catch (_) { return false; } }); const propertyKeyTypes = new Set([ "string", "number", "symbol" ]); function escapeRegex(str) { return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function clone(inst, def, params) { const cl = new inst._zod.constr(def ?? inst._zod.def); if (!def || params?.parent) cl._zod.parent = inst; return cl; } function normalizeParams(_params) { const params = _params; if (!params) return {}; if (typeof params === "string") return { error: () => params }; if (params?.message !== void 0) { if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params"); params.error = params.message; } delete params.message; if (typeof params.error === "string") return { ...params, error: () => params.error }; return params; } function optionalKeys(shape) { return Object.keys(shape).filter((k) => { return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional"; }); } Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE; function aborted(x, startIndex = 0) { if (x.aborted === true) return true; for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true; return false; } function prefixIssues(path, issues) { return issues.map((iss) => { var _a; (_a = iss).path ?? (_a.path = []); iss.path.unshift(path); return iss; }); } function unwrapMessage(message) { return typeof message === "string" ? message : message?.message; } function finalizeIssue(iss, ctx, config) { const full = { ...iss, path: iss.path ?? [] }; if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input"; delete full.inst; delete full.continue; if (!ctx?.reportInput) delete full.input; return full; } function getLengthableOrigin(input) { if (Array.isArray(input)) return "array"; if (typeof input === "string") return "string"; return "unknown"; } //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js const initializer = (inst, def) => { inst.name = "$ZodError"; Object.defineProperty(inst, "_zod", { value: inst._zod, enumerable: false }); Object.defineProperty(inst, "issues", { value: def, enumerable: false }); inst.message = JSON.stringify(def, jsonStringifyReplacer, 2); Object.defineProperty(inst, "toString", { value: () => inst.message, enumerable: false }); }; const $ZodError = $constructor("$ZodError", initializer); const $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error }); //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js const _parse = (_Err) => (schema, value, _ctx, _params) => { const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false }; const result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) throw new $ZodAsyncError(); if (result.issues.length) { const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))); captureStackTrace(e, _params?.callee); throw e; } return result.value; }; const parse = /* @__PURE__ */ _parse($ZodRealError); const _parseAsync = (_Err) => async (schema, value, _ctx, params) => { const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true }; let result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) result = await result; if (result.issues.length) { const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))); captureStackTrace(e, params?.callee); throw e; } return result.value; }; const parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError); const _safeParse = (_Err) => (schema, value, _ctx) => { const ctx = _ctx ? { ..._ctx, async: false } : { async: false }; const result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) throw new $ZodAsyncError(); return result.issues.length ? { success: false, error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))) } : { success: true, data: result.value }; }; const safeParse = /* @__PURE__ */ _safeParse($ZodRealError); const _safeParseAsync = (_Err) => async (schema, value, _ctx) => { const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true }; let result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) result = await result; return result.issues.length ? { success: false, error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))) } : { success: true, data: result.value }; }; const safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError); const string$1 = (params) => { const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`; return new RegExp(`^${regex}$`); }; const number$1 = /^-?\d+(?:\.\d+)?$/; //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => { var _a; inst._zod ?? (inst._zod = {}); inst._zod.def = def; (_a = inst._zod).onattach ?? (_a.onattach = []); }); const numericOriginMap = { number: "number", bigint: "bigint", object: "date" }; const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => { $ZodCheck.init(inst, def); const origin = numericOriginMap[typeof def.value]; inst._zod.onattach.push((inst) => { const bag = inst._zod.bag; const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY; if (def.value < curr) if (def.inclusive) bag.maximum = def.value; else bag.exclusiveMaximum = def.value; }); inst._zod.check = (payload) => { if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return; payload.issues.push({ origin, code: "too_big", maximum: typeof def.value === "object" ? def.value.getTime() : def.value, input: payload.value, inclusive: def.inclusive, inst, continue: !def.abort }); }; }); const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => { $ZodCheck.init(inst, def); const origin = numericOriginMap[typeof def.value]; inst._zod.onattach.push((inst) => { const bag = inst._zod.bag; const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY; if (def.value > curr) if (def.inclusive) bag.minimum = def.value; else bag.exclusiveMinimum = def.value; }); inst._zod.check = (payload) => { if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return; payload.issues.push({ origin, code: "too_small", minimum: typeof def.value === "object" ? def.value.getTime() : def.value, input: payload.value, inclusive: def.inclusive, inst, continue: !def.abort }); }; }); const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => { var _a; $ZodCheck.init(inst, def); (_a = inst._zod.def).when ?? (_a.when = (payload) => { const val = payload.value; return !nullish(val) && val.length !== void 0; }); inst._zod.onattach.push((inst) => { const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY; if (def.maximum < curr) inst._zod.bag.maximum = def.maximum; }); inst._zod.check = (payload) => { const input = payload.value; if (input.length <= def.maximum) return; const origin = getLengthableOrigin(input); payload.issues.push({ origin, code: "too_big", maximum: def.maximum, inclusive: true, input, inst, continue: !def.abort }); }; }); const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => { var _a; $ZodCheck.init(inst, def); (_a = inst._zod.def).when ?? (_a.when = (payload) => { const val = payload.value; return !nullish(val) && val.length !== void 0; }); inst._zod.onattach.push((inst) => { const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY; if (def.minimum > curr) inst._zod.bag.minimum = def.minimum; }); inst._zod.check = (payload) => { const input = payload.value; if (input.length >= def.minimum) return; const origin = getLengthableOrigin(input); payload.issues.push({ origin, code: "too_small", minimum: def.minimum, inclusive: true, input, inst, continue: !def.abort }); }; }); const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => { var _a, _b; $ZodCheck.init(inst, def); inst._zod.onattach.push((inst) => { const bag = inst._zod.bag; bag.format = def.format; if (def.pattern) { bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set()); bag.patterns.add(def.pattern); } }); if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => { def.pattern.lastIndex = 0; if (def.pattern.test(payload.value)) return; payload.issues.push({ origin: "string", code: "invalid_format", format: def.format, input: payload.value, ...def.pattern ? { pattern: def.pattern.toString() } : {}, inst, continue: !def.abort }); }); else (_b = inst._zod).check ?? (_b.check = () => {}); }); //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js const version = { major: 4, minor: 3, patch: 6 }; //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => { var _a; inst ?? (inst = {}); inst._zod.def = def; inst._zod.bag = inst._zod.bag || {}; inst._zod.version = version; const checks = [...inst._zod.def.checks ?? []]; if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst); for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst); if (checks.length === 0) { (_a = inst._zod).deferred ?? (_a.deferred = []); inst._zod.deferred?.push(() => { inst._zod.run = inst._zod.parse; }); } else { const runChecks = (payload, checks, ctx) => { let isAborted = aborted(payload); let asyncResult; for (const ch of checks) { if (ch._zod.def.when) { if (!ch._zod.def.when(payload)) continue; } else if (isAborted) continue; const currLen = payload.issues.length; const _ = ch._zod.check(payload); if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError(); if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => { await _; if (payload.issues.length === currLen) return; if (!isAborted) isAborted = aborted(payload, currLen); }); else { if (payload.issues.length === currLen) continue; if (!isAborted) isAborted = aborted(payload, currLen); } } if (asyncResult) return asyncResult.then(() => { return payload; }); return payload; }; const handleCanaryResult = (canary, payload, ctx) => { if (aborted(canary)) { canary.aborted = true; return canary; } const checkResult = runChecks(payload, checks, ctx); if (checkResult instanceof Promise) { if (ctx.async === false) throw new $ZodAsyncError(); return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx)); } return inst._zod.parse(checkResult, ctx); }; inst._zod.run = (payload, ctx) => { if (ctx.skipChecks) return inst._zod.parse(payload, ctx); if (ctx.direction === "backward") { const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true }); if (canary instanceof Promise) return canary.then((canary) => { return handleCanaryResult(canary, payload, ctx); }); return handleCanaryResult(canary, payload, ctx); } const result = inst._zod.parse(payload, ctx); if (result instanceof Promise) { if (ctx.async === false) throw new $ZodAsyncError(); return result.then((result) => runChecks(result, checks, ctx)); } return runChecks(result, checks, ctx); }; } defineLazy(inst, "~standard", () => ({ validate: (value) => { try { const r = safeParse(inst, value); return r.success ? { value: r.data } : { issues: r.error?.issues }; } catch (_) { return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues }); } }, vendor: "zod", version: 1 })); }); const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => { $ZodType.init(inst, def); inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag); inst._zod.parse = (payload, _) => { if (def.coerce) try { payload.value = String(payload.value); } catch (_) {} if (typeof payload.value === "string") return payload; payload.issues.push({ expected: "string", code: "invalid_type", input: payload.value, inst }); return payload; }; }); const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => { $ZodCheckStringFormat.init(inst, def); $ZodString.init(inst, def); }); const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => { $ZodStringFormat.init(inst, def); inst._zod.check = (payload) => { try { const trimmed = payload.value.trim(); const url = new URL(trimmed); if (def.hostname) { def.hostname.lastIndex = 0; if (!def.hostname.test(url.hostname)) payload.issues.push({ code: "invalid_format", format: "url", note: "Invalid hostname", pattern: def.hostname.source, input: payload.value, inst, continue: !def.abort }); } if (def.protocol) { def.protocol.lastIndex = 0; if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({ code: "invalid_format", format: "url", note: "Invalid protocol", pattern: def.protocol.source, input: payload.value, inst, continue: !def.abort }); } if (def.normalize) payload.value = url.href; else payload.value = trimmed; return; } catch (_) { payload.issues.push({ code: "invalid_format", format: "url", input: payload.value, inst, continue: !def.abort }); } }; }); const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => { $ZodType.init(inst, def); inst._zod.pattern = inst._zod.bag.pattern ?? number$1; inst._zod.parse = (payload, _ctx) => { if (def.coerce) try { payload.value = Number(payload.value); } catch (_) {} const input = payload.value; if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload; const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0; payload.issues.push({ expected: "number", code: "invalid_type", input, inst, ...received ? { received } : {} }); return payload; }; }); const $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => { $ZodType.init(inst, def); inst._zod.parse = (payload, _ctx) => { if (def.coerce) try { payload.value = new Date(payload.value); } catch (_err) {} const input = payload.value; const isDate = input instanceof Date; if (isDate && !Number.isNaN(input.getTime())) return payload; payload.issues.push({ expected: "date", code: "invalid_type", input, ...isDate ? { received: "Invalid Date" } : {}, inst }); return payload; }; }); function handleArrayResult(result, final, index) { if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues)); final.value[index] = result.value; } const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => { $ZodType.init(inst, def); inst._zod.parse = (payload, ctx) => { const input = payload.value; if (!Array.isArray(input)) { payload.issues.push({ expected: "array", code: "invalid_type", input, inst }); return payload; } payload.value = Array(input.length); const proms = []; for (let i = 0; i < input.length; i++) { const item = input[i]; const result = def.element._zod.run({ value: item, issues: [] }, ctx); if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i))); else handleArrayResult(result, payload, i); } if (proms.length) return Promise.all(proms).then(() => payload); return payload; }; }); function handlePropertyResult(result, final, key, input, isOptionalOut) { if (result.issues.length) { if (isOptionalOut && !(key in input)) return; final.issues.push(...prefixIssues(key, result.issues)); } if (result.value === void 0) { if (key in input) final.value[key] = void 0; } else final.value[key] = result.value; } function normalizeDef(def) { const keys = Object.keys(def.shape); for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`); const okeys = optionalKeys(def.shape); return { ...def, keys, keySet: new Set(keys), numKeys: keys.length, optionalKeys: new Set(okeys) }; } function handleCatchall(proms, input, payload, ctx, def, inst) { const unrecognized = []; const keySet = def.keySet; const _catchall = def.catchall._zod; const t = _catchall.def.type; const isOptionalOut = _catchall.optout === "optional"; for (const key in input) { if (keySet.has(key)) continue; if (t === "never") { unrecognized.push(key); continue; } const r = _catchall.run({ value: input[key], issues: [] }, ctx); if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut))); else handlePropertyResult(r, payload, key, input, isOptionalOut); } if (unrecognized.length) payload.issues.push({ code: "unrecognized_keys", keys: unrecognized, input, inst }); if (!proms.length) return payload; return Promise.all(proms).then(() => { return payload; }); } const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => { $ZodType.init(inst, def); if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) { const sh = def.shape; Object.defineProperty(def, "shape", { get: () => { const newSh = { ...sh }; Object.defineProperty(def, "shape", { value: newSh }); return newSh; } }); } const _normalized = cached(() => normalizeDef(def)); defineLazy(inst._zod, "propValues", () => { const shape = def.shape; const propValues = {}; for (const key in shape) { const field = shape[key]._zod; if (field.values) { propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set()); for (const v of field.values) propValues[key].add(v); } } return propValues; }); const isObject$2 = isObject; const catchall = def.catchall; let value; inst._zod.parse = (payload, ctx) => { value ?? (value = _normalized.value); const input = payload.value; if (!isObject$2(input)) { payload.issues.push({ expected: "object", code: "invalid_type", input, inst }); return payload; } payload.value = {}; const proms = []; const shape = value.shape; for (const key of value.keys) { const el = shape[key]; const isOptionalOut = el._zod.optout === "optional"; const r = el._zod.run({ value: input[key], issues: [] }, ctx); if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut))); else handlePropertyResult(r, payload, key, input, isOptionalOut); } if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload; return handleCatchall(proms, input, payload, ctx, _normalized.value, inst); }; }); const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => { $ZodType.init(inst, def); const values = getEnumValues(def.entries); const valuesSet = new Set(values); inst._zod.values = valuesSet; inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`); inst._zod.parse = (payload, _ctx) => { const input = payload.value; if (valuesSet.has(input)) return payload; payload.issues.push({ code: "invalid_value", values, input, inst }); return payload; }; }); const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => { $ZodType.init(inst, def); defineLazy(inst._zod, "optin", () => def.innerType._zod.optin); defineLazy(inst._zod, "optout", () => def.innerType._zod.optout); defineLazy(inst._zod, "pattern", () => { const pattern = def.innerType._zod.pattern; return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0; }); defineLazy(inst._zod, "values", () => { return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0; }); inst._zod.parse = (payload, ctx) => { if (payload.value === null) return payload; return def.innerType._zod.run(payload, ctx); }; }); //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js /* @__NO_SIDE_EFFECTS__ */ function _string(Class, params) { return new Class({ type: "string", ...normalizeParams(params) }); } /* @__NO_SIDE_EFFECTS__ */ function _url(Class, params) { return new Class({ type: "string", format: "url", check: "string_format", abort: false, ...normalizeParams(params) }); } /* @__NO_SIDE_EFFECTS__ */ function _number(Class, params) { return new Class({ type: "number", checks: [], ...normalizeParams(params) }); } /* @__NO_SIDE_EFFECTS__ */ function _date(Class, params) { return new Class({ type: "date", ...normalizeParams(params) }); } /* @__NO_SIDE_EFFECTS__ */ function _lte(value, params) { return new $ZodCheckLessThan({ check: "less_than", ...normalizeParams(params), value, inclusive: true }); } /* @__NO_SIDE_EFFECTS__ */ function _gte(value, params) { return new $ZodCheckGreaterThan({ check: "greater_than", ...normalizeParams(params), value, inclusive: true }); } /* @__NO_SIDE_EFFECTS__ */ function _maxLength(maximum, params) { return new $ZodCheckMaxLength({ check: "max_length", ...normalizeParams(params), maximum }); } /* @__NO_SIDE_EFFECTS__ */ function _minLength(minimum, params) { return new $ZodCheckMinLength({ check: "min_length", ...normalizeParams(params), minimum }); } //#endregion //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/mini/schemas.js const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => { if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType."); $ZodType.init(inst, def); inst.def = def; inst.type = def.type; inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse }); inst.safeParse = (data, params) => safeParse(inst, data, params); inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync }); inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params); inst.check = (...checks) => { return inst.clone({ ...def, checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)] }, { parent: true }); }; inst.with = inst.check; inst.clone = (_def, params) => clone(inst, _def, params); inst.brand = () => inst; inst.register = ((reg, meta) => { reg.add(inst, meta); return inst; }); inst.apply = (fn) => fn(inst); }); const ZodMiniString = /* @__PURE__ */ $constructor("ZodMiniString", (inst, def) => { $ZodString.init(inst, def); ZodMiniType.init(inst, def); }); /* @__NO_SIDE_EFFECTS__ */ function string(params) { return /* @__PURE__ */ _string(ZodMiniString, params); } const ZodMiniStringFormat = /* @__PURE__ */ $constructor("ZodMiniStringFormat", (inst, def) => { $ZodStringFormat.init(inst, def); ZodMiniString.init(inst, def); }); const ZodMiniURL = /* @__PURE__ */ $constructor("ZodMiniURL", (inst, def) => { $ZodURL.init(inst, def); ZodMiniStringFormat.init(inst, def); }); /* @__NO_SIDE_EFFECTS__ */ function url(params) { return /* @__PURE__ */ _url(ZodMiniURL, params); } const ZodMiniNumber = /* @__PURE__ */ $constructor("ZodMiniNumber", (inst, def) => { $ZodNumber.init(inst, def); ZodMiniType.init(inst, def); }); /* @__NO_SIDE_EFFECTS__ */ function number(params) { return /* @__PURE__ */ _number(ZodMiniNumber, params); } const ZodMiniDate = /* @__PURE__ */ $constructor("ZodMiniDate", (inst, def) => { $ZodDate.init(inst, def); ZodMiniType.init(inst, def); }); /* @__NO_SIDE_EFFECTS__ */ function date(params) { return /* @__PURE__ */ _date(ZodMiniDate, params); } const ZodMiniArray = /* @__PURE__ */ $constructor("ZodMiniArray", (inst, def) => { $ZodArray.init(inst, def); ZodMiniType.init(inst, def); }); /* @__NO_SIDE_EFFECTS__ */ function array(element, params) { return new ZodMiniArray({ type: "array", element, ...normalizeParams(params) }); } const ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => { $ZodObject.init(inst, def); ZodMiniType.init(inst, def); defineLazy(inst, "shape", () => def.shape); }); /* @__NO_SIDE_EFFECTS__ */ function object(shape, params) { return new ZodMiniObject({ type: "object", shape: shape ?? {}, ...normalizeParams(params) }); } const ZodMiniEnum = /* @__PURE__ */ $constructor("ZodMiniEnum", (inst, def) => { $ZodEnum.init(inst, def); ZodMiniType.init(inst, def); inst.options = Object.values(def.entries); }); /* @__NO_SIDE_EFFECTS__ */ function _enum(values, params) { return new ZodMiniEnum({ type: "enum", entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values, ...normalizeParams(params) }); } const ZodMiniNullable = /* @__PURE__ */ $constructor("ZodMiniNullable", (inst, def) => { $ZodNullable.init(inst, def); ZodMiniType.init(inst, def); }); /* @__NO_SIDE_EFFECTS__ */ function nullable(innerType) { return new ZodMiniNullable({ type: "nullable", innerType }); } //#endregion //#region ../schemas/libraries/zod/mini/download.ts const imageSchema = /* @__PURE__ */ object({ id: /* @__PURE__ */ number(), created: /* @__PURE__ */ date(), title: (/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(100)), type: /* @__PURE__ */ _enum(["jpg", "png"]), size: /* @__PURE__ */ number(), url: /* @__PURE__ */ url() }); const ratingSchema = /* @__PURE__ */ object({ id: /* @__PURE__ */ number(), stars: (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(5)), title: (/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(100)), text: (/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(1e3)), images: /* @__PURE__ */ array(imageSchema) }); (/* @__PURE__ */ object({ id: /* @__PURE__ */ number(), created: /* @__PURE__ */ date(), title: (/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(100)), brand: (/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(30)), description: (/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(500)), price: (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(1), /* @__PURE__ */ _lte(1e4)), discount: /* @__PURE__ */ nullable((/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(1), /* @__PURE__ */ _lte(100))), quantity: (/* @__PURE__ */ number()).check(/* @__PURE__ */ _gte(0), /* @__PURE__ */ _lte(10)), tags: /* @__PURE__ */ array((/* @__PURE__ */ string()).check(/* @__PURE__ */ _minLength(1), /* @__PURE__ */ _maxLength(30))), images: /* @__PURE__ */ array(imageSchema), ratings: /* @__PURE__ */ array(ratingSchema) })).parse({}); //#endregion
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser