123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842 |
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ZodMiniTransform = exports.ZodMiniFile = exports.ZodMiniLiteral = exports.ZodMiniEnum = exports.ZodMiniSet = exports.ZodMiniMap = exports.ZodMiniRecord = exports.ZodMiniTuple = exports.ZodMiniIntersection = exports.ZodMiniDiscriminatedUnion = exports.ZodMiniUnion = exports.ZodMiniObject = exports.ZodMiniArray = exports.ZodMiniDate = exports.ZodMiniVoid = exports.ZodMiniNever = exports.ZodMiniUnknown = exports.ZodMiniAny = exports.ZodMiniNull = exports.ZodMiniUndefined = exports.ZodMiniSymbol = exports.ZodMiniBigIntFormat = exports.ZodMiniBigInt = exports.ZodMiniBoolean = exports.ZodMiniNumberFormat = exports.ZodMiniNumber = exports.ZodMiniJWT = exports.ZodMiniE164 = exports.ZodMiniBase64URL = exports.ZodMiniBase64 = exports.ZodMiniCIDRv6 = exports.ZodMiniCIDRv4 = exports.ZodMiniIPv6 = exports.ZodMiniIPv4 = exports.ZodMiniKSUID = exports.ZodMiniXID = exports.ZodMiniULID = exports.ZodMiniCUID2 = exports.ZodMiniCUID = exports.ZodMiniNanoID = exports.ZodMiniEmoji = exports.ZodMiniURL = exports.ZodMiniUUID = exports.ZodMiniGUID = exports.ZodMiniEmail = exports.ZodMiniStringFormat = exports.ZodMiniString = exports.ZodMiniType = exports.iso = exports.coerce = void 0;
- exports.stringbool = exports.ZodMiniCustom = exports.ZodMiniPromise = exports.ZodMiniLazy = exports.ZodMiniTemplateLiteral = exports.ZodMiniReadonly = exports.ZodMiniPipe = exports.ZodMiniNaN = exports.ZodMiniCatch = exports.ZodMiniSuccess = exports.ZodMiniNonOptional = exports.ZodMiniPrefault = exports.ZodMiniDefault = exports.ZodMiniNullable = exports.ZodMiniOptional = void 0;
- exports.string = string;
- exports.email = email;
- exports.guid = guid;
- exports.uuid = uuid;
- exports.uuidv4 = uuidv4;
- exports.uuidv6 = uuidv6;
- exports.uuidv7 = uuidv7;
- exports.url = url;
- exports.emoji = emoji;
- exports.nanoid = nanoid;
- exports.cuid = cuid;
- exports.cuid2 = cuid2;
- exports.ulid = ulid;
- exports.xid = xid;
- exports.ksuid = ksuid;
- exports.ipv4 = ipv4;
- exports.ipv6 = ipv6;
- exports.cidrv4 = cidrv4;
- exports.cidrv6 = cidrv6;
- exports.base64 = base64;
- exports.base64url = base64url;
- exports.e164 = e164;
- exports.jwt = jwt;
- exports.number = number;
- exports.int = int;
- exports.float32 = float32;
- exports.float64 = float64;
- exports.int32 = int32;
- exports.uint32 = uint32;
- exports.boolean = boolean;
- exports.bigint = bigint;
- exports.int64 = int64;
- exports.uint64 = uint64;
- exports.symbol = symbol;
- exports.undefined = _undefined;
- exports.null = _null;
- exports.any = any;
- exports.unknown = unknown;
- exports.never = never;
- exports.void = _void;
- exports.date = date;
- exports.array = array;
- exports.keyof = keyof;
- exports.object = object;
- exports.strictObject = strictObject;
- exports.looseObject = looseObject;
- exports.extend = extend;
- exports.merge = merge;
- exports.pick = pick;
- exports.omit = omit;
- exports.partial = partial;
- exports.required = required;
- exports.union = union;
- exports.discriminatedUnion = discriminatedUnion;
- exports.intersection = intersection;
- exports.tuple = tuple;
- exports.record = record;
- exports.partialRecord = partialRecord;
- exports.map = map;
- exports.set = set;
- exports.enum = _enum;
- exports.nativeEnum = nativeEnum;
- exports.literal = literal;
- exports.file = file;
- exports.transform = transform;
- exports.optional = optional;
- exports.nullable = nullable;
- exports.nullish = nullish;
- exports._default = _default;
- exports.prefault = prefault;
- exports.nonoptional = nonoptional;
- exports.success = success;
- exports.catch = _catch;
- exports.nan = nan;
- exports.pipe = pipe;
- exports.readonly = readonly;
- exports.templateLiteral = templateLiteral;
- exports.lazy = _lazy;
- exports.promise = promise;
- exports.check = check;
- exports.refine = refine;
- exports.custom = custom;
- exports.instanceof = _instanceof;
- exports.json = json;
- const core = __importStar(require("zod/v4/core"));
- const core_1 = require("zod/v4/core");
- const parse = __importStar(require("./parse.js"));
- exports.coerce = __importStar(require("./coerce.js"));
- exports.iso = __importStar(require("./iso.js"));
- exports.ZodMiniType = core.$constructor("ZodMiniType", (inst, def) => {
- if (!inst._zod)
- throw new Error("Uninitialized schema in mixin ZodMiniType.");
- core.$ZodType.init(inst, def);
- inst.def = def;
- inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
- inst.safeParse = (data, params) => parse.safeParse(inst, data, params);
- inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
- inst.safeParseAsync = async (data, params) => parse.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.clone = (_def, params) => core.clone(inst, _def, params);
- inst.brand = () => inst;
- inst.register = ((reg, meta) => {
- reg.add(inst, meta);
- return inst;
- });
- });
- exports.ZodMiniString = core.$constructor("ZodMiniString", (inst, def) => {
- core.$ZodString.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function string(params) {
- return core._string(exports.ZodMiniString, params);
- }
- exports.ZodMiniStringFormat = core.$constructor("ZodMiniStringFormat", (inst, def) => {
- core.$ZodStringFormat.init(inst, def);
- exports.ZodMiniString.init(inst, def);
- });
- exports.ZodMiniEmail = core.$constructor("ZodMiniEmail", (inst, def) => {
- core.$ZodEmail.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function email(params) {
- return core._email(exports.ZodMiniEmail, params);
- }
- exports.ZodMiniGUID = core.$constructor("ZodMiniGUID", (inst, def) => {
- core.$ZodGUID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function guid(params) {
- return core._guid(exports.ZodMiniGUID, params);
- }
- exports.ZodMiniUUID = core.$constructor("ZodMiniUUID", (inst, def) => {
- core.$ZodUUID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function uuid(params) {
- return core._uuid(exports.ZodMiniUUID, params);
- }
- function uuidv4(params) {
- return core._uuidv4(exports.ZodMiniUUID, params);
- }
- // ZodMiniUUIDv6
- function uuidv6(params) {
- return core._uuidv6(exports.ZodMiniUUID, params);
- }
- // ZodMiniUUIDv7
- function uuidv7(params) {
- return core._uuidv7(exports.ZodMiniUUID, params);
- }
- exports.ZodMiniURL = core.$constructor("ZodMiniURL", (inst, def) => {
- core.$ZodURL.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function url(params) {
- return core._url(exports.ZodMiniURL, params);
- }
- exports.ZodMiniEmoji = core.$constructor("ZodMiniEmoji", (inst, def) => {
- core.$ZodEmoji.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function emoji(params) {
- return core._emoji(exports.ZodMiniEmoji, params);
- }
- exports.ZodMiniNanoID = core.$constructor("ZodMiniNanoID", (inst, def) => {
- core.$ZodNanoID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function nanoid(params) {
- return core._nanoid(exports.ZodMiniNanoID, params);
- }
- exports.ZodMiniCUID = core.$constructor("ZodMiniCUID", (inst, def) => {
- core.$ZodCUID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function cuid(params) {
- return core._cuid(exports.ZodMiniCUID, params);
- }
- exports.ZodMiniCUID2 = core.$constructor("ZodMiniCUID2", (inst, def) => {
- core.$ZodCUID2.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function cuid2(params) {
- return core._cuid2(exports.ZodMiniCUID2, params);
- }
- exports.ZodMiniULID = core.$constructor("ZodMiniULID", (inst, def) => {
- core.$ZodULID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function ulid(params) {
- return core._ulid(exports.ZodMiniULID, params);
- }
- exports.ZodMiniXID = core.$constructor("ZodMiniXID", (inst, def) => {
- core.$ZodXID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function xid(params) {
- return core._xid(exports.ZodMiniXID, params);
- }
- exports.ZodMiniKSUID = core.$constructor("ZodMiniKSUID", (inst, def) => {
- core.$ZodKSUID.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function ksuid(params) {
- return core._ksuid(exports.ZodMiniKSUID, params);
- }
- exports.ZodMiniIPv4 = core.$constructor("ZodMiniIPv4", (inst, def) => {
- core.$ZodIPv4.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function ipv4(params) {
- return core._ipv4(exports.ZodMiniIPv4, params);
- }
- exports.ZodMiniIPv6 = core.$constructor("ZodMiniIPv6", (inst, def) => {
- core.$ZodIPv6.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function ipv6(params) {
- return core._ipv6(exports.ZodMiniIPv6, params);
- }
- exports.ZodMiniCIDRv4 = core.$constructor("ZodMiniCIDRv4", (inst, def) => {
- core.$ZodCIDRv4.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function cidrv4(params) {
- return core._cidrv4(exports.ZodMiniCIDRv4, params);
- }
- exports.ZodMiniCIDRv6 = core.$constructor("ZodMiniCIDRv6", (inst, def) => {
- core.$ZodCIDRv6.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function cidrv6(params) {
- return core._cidrv6(exports.ZodMiniCIDRv6, params);
- }
- exports.ZodMiniBase64 = core.$constructor("ZodMiniBase64", (inst, def) => {
- core.$ZodBase64.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function base64(params) {
- return core._base64(exports.ZodMiniBase64, params);
- }
- exports.ZodMiniBase64URL = core.$constructor("ZodMiniBase64URL", (inst, def) => {
- core.$ZodBase64URL.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function base64url(params) {
- return core._base64url(exports.ZodMiniBase64URL, params);
- }
- exports.ZodMiniE164 = core.$constructor("ZodMiniE164", (inst, def) => {
- core.$ZodE164.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function e164(params) {
- return core._e164(exports.ZodMiniE164, params);
- }
- exports.ZodMiniJWT = core.$constructor("ZodMiniJWT", (inst, def) => {
- core.$ZodJWT.init(inst, def);
- exports.ZodMiniStringFormat.init(inst, def);
- });
- function jwt(params) {
- return core._jwt(exports.ZodMiniJWT, params);
- }
- exports.ZodMiniNumber = core.$constructor("ZodMiniNumber", (inst, def) => {
- core.$ZodNumber.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function number(params) {
- return core._number(exports.ZodMiniNumber, params);
- }
- exports.ZodMiniNumberFormat = core.$constructor("ZodMiniNumberFormat", (inst, def) => {
- core.$ZodNumberFormat.init(inst, def);
- exports.ZodMiniNumber.init(inst, def);
- });
- // int
- function int(params) {
- return core._int(exports.ZodMiniNumberFormat, params);
- }
- // float32
- function float32(params) {
- return core._float32(exports.ZodMiniNumberFormat, params);
- }
- // float64
- function float64(params) {
- return core._float64(exports.ZodMiniNumberFormat, params);
- }
- // int32
- function int32(params) {
- return core._int32(exports.ZodMiniNumberFormat, params);
- }
- // uint32
- function uint32(params) {
- return core._uint32(exports.ZodMiniNumberFormat, params);
- }
- exports.ZodMiniBoolean = core.$constructor("ZodMiniBoolean", (inst, def) => {
- core.$ZodBoolean.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function boolean(params) {
- return core._boolean(exports.ZodMiniBoolean, params);
- }
- exports.ZodMiniBigInt = core.$constructor("ZodMiniBigInt", (inst, def) => {
- core.$ZodBigInt.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function bigint(params) {
- return core._bigint(exports.ZodMiniBigInt, params);
- }
- exports.ZodMiniBigIntFormat = core.$constructor("ZodMiniBigIntFormat", (inst, def) => {
- core.$ZodBigIntFormat.init(inst, def);
- exports.ZodMiniBigInt.init(inst, def);
- });
- // int64
- function int64(params) {
- return core._int64(exports.ZodMiniBigIntFormat, params);
- }
- // uint64
- function uint64(params) {
- return core._uint64(exports.ZodMiniBigIntFormat, params);
- }
- exports.ZodMiniSymbol = core.$constructor("ZodMiniSymbol", (inst, def) => {
- core.$ZodSymbol.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function symbol(params) {
- return core._symbol(exports.ZodMiniSymbol, params);
- }
- exports.ZodMiniUndefined = core.$constructor("ZodMiniUndefined", (inst, def) => {
- core.$ZodUndefined.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function _undefined(params) {
- return core._undefined(exports.ZodMiniUndefined, params);
- }
- exports.ZodMiniNull = core.$constructor("ZodMiniNull", (inst, def) => {
- core.$ZodNull.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function _null(params) {
- return core._null(exports.ZodMiniNull, params);
- }
- exports.ZodMiniAny = core.$constructor("ZodMiniAny", (inst, def) => {
- core.$ZodAny.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function any() {
- return core._any(exports.ZodMiniAny);
- }
- exports.ZodMiniUnknown = core.$constructor("ZodMiniUnknown", (inst, def) => {
- core.$ZodUnknown.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function unknown() {
- return core._unknown(exports.ZodMiniUnknown);
- }
- exports.ZodMiniNever = core.$constructor("ZodMiniNever", (inst, def) => {
- core.$ZodNever.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function never(params) {
- return core._never(exports.ZodMiniNever, params);
- }
- exports.ZodMiniVoid = core.$constructor("ZodMiniVoid", (inst, def) => {
- core.$ZodVoid.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function _void(params) {
- return core._void(exports.ZodMiniVoid, params);
- }
- exports.ZodMiniDate = core.$constructor("ZodMiniDate", (inst, def) => {
- core.$ZodDate.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function date(params) {
- return core._date(exports.ZodMiniDate, params);
- }
- exports.ZodMiniArray = core.$constructor("ZodMiniArray", (inst, def) => {
- core.$ZodArray.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function array(element, params) {
- return new exports.ZodMiniArray({
- type: "array",
- element,
- // get element() {
- // return element;
- // },
- ...core_1.util.normalizeParams(params),
- });
- }
- // .keyof
- function keyof(schema) {
- const shape = schema._zod.def.shape;
- return literal(Object.keys(shape));
- }
- exports.ZodMiniObject = core.$constructor("ZodMiniObject", (inst, def) => {
- core.$ZodObject.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function object(shape, params) {
- const def = {
- type: "object",
- get shape() {
- core_1.util.assignProp(this, "shape", { ...shape });
- return this.shape;
- },
- ...core_1.util.normalizeParams(params),
- };
- return new exports.ZodMiniObject(def);
- }
- // strictObject
- function strictObject(shape, params) {
- return new exports.ZodMiniObject({
- type: "object",
- // shape: shape as core.$ZodLooseShape,
- get shape() {
- core_1.util.assignProp(this, "shape", { ...shape });
- return this.shape;
- },
- // get optional() {
- // return util.optionalKeys(shape);
- // },
- catchall: never(),
- ...core_1.util.normalizeParams(params),
- });
- }
- // looseObject
- function looseObject(shape, params) {
- return new exports.ZodMiniObject({
- type: "object",
- // shape: shape as core.$ZodLooseShape,
- get shape() {
- core_1.util.assignProp(this, "shape", { ...shape });
- return this.shape;
- },
- // get optional() {
- // return util.optionalKeys(shape);
- // },
- catchall: unknown(),
- ...core_1.util.normalizeParams(params),
- });
- }
- // object methods
- function extend(schema, shape) {
- return core_1.util.extend(schema, shape);
- }
- function merge(schema, shape) {
- return core_1.util.extend(schema, shape);
- }
- function pick(schema, mask) {
- return core_1.util.pick(schema, mask);
- }
- // .omit
- function omit(schema, mask) {
- return core_1.util.omit(schema, mask);
- }
- function partial(schema, mask) {
- return core_1.util.partial(exports.ZodMiniOptional, schema, mask);
- }
- function required(schema, mask) {
- return core_1.util.required(exports.ZodMiniNonOptional, schema, mask);
- }
- exports.ZodMiniUnion = core.$constructor("ZodMiniUnion", (inst, def) => {
- core.$ZodUnion.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function union(options, params) {
- return new exports.ZodMiniUnion({
- type: "union",
- options,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniDiscriminatedUnion = core.$constructor("ZodMiniDiscriminatedUnion", (inst, def) => {
- core.$ZodDiscriminatedUnion.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function discriminatedUnion(discriminator, options, params) {
- return new exports.ZodMiniDiscriminatedUnion({
- type: "union",
- options,
- discriminator,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniIntersection = core.$constructor("ZodMiniIntersection", (inst, def) => {
- core.$ZodIntersection.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function intersection(left, right) {
- return new exports.ZodMiniIntersection({
- type: "intersection",
- left,
- right,
- });
- }
- exports.ZodMiniTuple = core.$constructor("ZodMiniTuple", (inst, def) => {
- core.$ZodTuple.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function tuple(items, _paramsOrRest, _params) {
- const hasRest = _paramsOrRest instanceof core.$ZodType;
- const params = hasRest ? _params : _paramsOrRest;
- const rest = hasRest ? _paramsOrRest : null;
- return new exports.ZodMiniTuple({
- type: "tuple",
- items,
- rest,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniRecord = core.$constructor("ZodMiniRecord", (inst, def) => {
- core.$ZodRecord.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function record(keyType, valueType, params) {
- return new exports.ZodMiniRecord({
- type: "record",
- keyType,
- valueType,
- ...core_1.util.normalizeParams(params),
- });
- }
- function partialRecord(keyType, valueType, params) {
- return new exports.ZodMiniRecord({
- type: "record",
- keyType: union([keyType, never()]),
- valueType,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniMap = core.$constructor("ZodMiniMap", (inst, def) => {
- core.$ZodMap.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function map(keyType, valueType, params) {
- return new exports.ZodMiniMap({
- type: "map",
- keyType,
- valueType,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniSet = core.$constructor("ZodMiniSet", (inst, def) => {
- core.$ZodSet.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function set(valueType, params) {
- return new exports.ZodMiniSet({
- type: "set",
- valueType,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniEnum = core.$constructor("ZodMiniEnum", (inst, def) => {
- core.$ZodEnum.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function _enum(values, params) {
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
- return new exports.ZodMiniEnum({
- type: "enum",
- entries,
- ...core_1.util.normalizeParams(params),
- });
- }
- /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
- *
- * ```ts
- * enum Colors { red, green, blue }
- * z.enum(Colors);
- * ```
- */
- function nativeEnum(entries, params) {
- return new exports.ZodMiniEnum({
- type: "enum",
- entries,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniLiteral = core.$constructor("ZodMiniLiteral", (inst, def) => {
- core.$ZodLiteral.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function literal(value, params) {
- return new exports.ZodMiniLiteral({
- type: "literal",
- values: Array.isArray(value) ? value : [value],
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniFile = core.$constructor("ZodMiniFile", (inst, def) => {
- core.$ZodFile.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function file(params) {
- return core._file(exports.ZodMiniFile, params);
- }
- exports.ZodMiniTransform = core.$constructor("ZodMiniTransform", (inst, def) => {
- core.$ZodTransform.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function transform(fn) {
- return new exports.ZodMiniTransform({
- type: "transform",
- transform: fn,
- });
- }
- exports.ZodMiniOptional = core.$constructor("ZodMiniOptional", (inst, def) => {
- core.$ZodOptional.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function optional(innerType) {
- return new exports.ZodMiniOptional({
- type: "optional",
- innerType,
- });
- }
- exports.ZodMiniNullable = core.$constructor("ZodMiniNullable", (inst, def) => {
- core.$ZodNullable.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function nullable(innerType) {
- return new exports.ZodMiniNullable({
- type: "nullable",
- innerType,
- });
- }
- // nullish
- function nullish(innerType) {
- return optional(nullable(innerType));
- }
- exports.ZodMiniDefault = core.$constructor("ZodMiniDefault", (inst, def) => {
- core.$ZodDefault.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function _default(innerType, defaultValue) {
- return new exports.ZodMiniDefault({
- type: "default",
- innerType,
- get defaultValue() {
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
- },
- });
- }
- exports.ZodMiniPrefault = core.$constructor("ZodMiniPrefault", (inst, def) => {
- core.$ZodPrefault.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function prefault(innerType, defaultValue) {
- return new exports.ZodMiniPrefault({
- type: "prefault",
- innerType,
- get defaultValue() {
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
- },
- });
- }
- exports.ZodMiniNonOptional = core.$constructor("ZodMiniNonOptional", (inst, def) => {
- core.$ZodNonOptional.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function nonoptional(innerType, params) {
- return new exports.ZodMiniNonOptional({
- type: "nonoptional",
- innerType,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniSuccess = core.$constructor("ZodMiniSuccess", (inst, def) => {
- core.$ZodSuccess.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function success(innerType) {
- return new exports.ZodMiniSuccess({
- type: "success",
- innerType,
- });
- }
- exports.ZodMiniCatch = core.$constructor("ZodMiniCatch", (inst, def) => {
- core.$ZodCatch.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function _catch(innerType, catchValue) {
- return new exports.ZodMiniCatch({
- type: "catch",
- innerType,
- catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
- });
- }
- exports.ZodMiniNaN = core.$constructor("ZodMiniNaN", (inst, def) => {
- core.$ZodNaN.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function nan(params) {
- return core._nan(exports.ZodMiniNaN, params);
- }
- exports.ZodMiniPipe = core.$constructor("ZodMiniPipe", (inst, def) => {
- core.$ZodPipe.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function pipe(in_, out) {
- return new exports.ZodMiniPipe({
- type: "pipe",
- in: in_,
- out,
- });
- }
- exports.ZodMiniReadonly = core.$constructor("ZodMiniReadonly", (inst, def) => {
- core.$ZodReadonly.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function readonly(innerType) {
- return new exports.ZodMiniReadonly({
- type: "readonly",
- innerType,
- });
- }
- exports.ZodMiniTemplateLiteral = core.$constructor("ZodMiniTemplateLiteral", (inst, def) => {
- core.$ZodTemplateLiteral.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function templateLiteral(parts, params) {
- return new exports.ZodMiniTemplateLiteral({
- type: "template_literal",
- parts,
- ...core_1.util.normalizeParams(params),
- });
- }
- exports.ZodMiniLazy = core.$constructor("ZodMiniLazy", (inst, def) => {
- core.$ZodLazy.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- // export function lazy<T extends object>(getter: () => T): T {
- // return util.createTransparentProxy<T>(getter);
- // }
- function _lazy(getter) {
- return new exports.ZodMiniLazy({
- type: "lazy",
- getter,
- });
- }
- exports.ZodMiniPromise = core.$constructor("ZodMiniPromise", (inst, def) => {
- core.$ZodPromise.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- function promise(innerType) {
- return new exports.ZodMiniPromise({
- type: "promise",
- innerType,
- });
- }
- exports.ZodMiniCustom = core.$constructor("ZodMiniCustom", (inst, def) => {
- core.$ZodCustom.init(inst, def);
- exports.ZodMiniType.init(inst, def);
- });
- // custom checks
- function check(fn, params) {
- const ch = new core.$ZodCheck({
- check: "custom",
- ...core_1.util.normalizeParams(params),
- });
- ch._zod.check = fn;
- return ch;
- }
- // ZodCustom
- function _custom(fn, _params, Class) {
- const params = core_1.util.normalizeParams(_params);
- const schema = new Class({
- type: "custom",
- check: "custom",
- fn: fn,
- ...params,
- });
- return schema;
- }
- // refine
- function refine(fn, _params = {}) {
- return _custom(fn, _params, exports.ZodMiniCustom);
- }
- // custom schema
- function custom(fn, _params) {
- return _custom(fn ?? (() => true), _params, exports.ZodMiniCustom);
- }
- // instanceof
- class Class {
- constructor(..._args) { }
- }
- function _instanceof(cls, params = {
- error: `Input not instance of ${cls.name}`,
- }) {
- const inst = custom((data) => data instanceof cls, params);
- inst._zod.bag.Class = cls;
- return inst;
- }
- // stringbool
- exports.stringbool = core._stringbool.bind(null, {
- Pipe: exports.ZodMiniPipe,
- Boolean: exports.ZodMiniBoolean,
- Unknown: exports.ZodMiniUnknown,
- });
- function json() {
- const jsonSchema = _lazy(() => {
- return union([string(), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
- });
- return jsonSchema;
- }
|