CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
types.cjs3778 linesDownload Raw Back to v3
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;4exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = void 0;5exports.datetimeRegex = datetimeRegex;6exports.custom = custom;7const ZodError_js_1 = require("./ZodError.cjs");8const errors_js_1 = require("./errors.cjs");9const errorUtil_js_1 = require("./helpers/errorUtil.cjs");10const parseUtil_js_1 = require("./helpers/parseUtil.cjs");11const util_js_1 = require("./helpers/util.cjs");12class ParseInputLazyPath {13    constructor(parent, value, path, key) {14        this._cachedPath = [];15        this.parent = parent;16        this.data = value;17        this._path = path;18        this._key = key;19    }20    get path() {21        if (!this._cachedPath.length) {22            if (Array.isArray(this._key)) {23                this._cachedPath.push(...this._path, ...this._key);24            }25            else {26                this._cachedPath.push(...this._path, this._key);27            }28        }29        return this._cachedPath;30    }31}32const handleResult = (ctx, result) => {33    if ((0, parseUtil_js_1.isValid)(result)) {34        return { success: true, data: result.value };35    }36    else {37        if (!ctx.common.issues.length) {38            throw new Error("Validation failed but no issues detected.");39        }40        return {41            success: false,42            get error() {43                if (this._error)44                    return this._error;45                const error = new ZodError_js_1.ZodError(ctx.common.issues);46                this._error = error;47                return this._error;48            },49        };50    }51};52function processCreateParams(params) {53    if (!params)54        return {};55    const { errorMap, invalid_type_error, required_error, description } = params;56    if (errorMap && (invalid_type_error || required_error)) {57        throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);58    }59    if (errorMap)60        return { errorMap: errorMap, description };61    const customMap = (iss, ctx) => {62        const { message } = params;63        if (iss.code === "invalid_enum_value") {64            return { message: message ?? ctx.defaultError };65        }66        if (typeof ctx.data === "undefined") {67            return { message: message ?? required_error ?? ctx.defaultError };68        }69        if (iss.code !== "invalid_type")70            return { message: ctx.defaultError };71        return { message: message ?? invalid_type_error ?? ctx.defaultError };72    };73    return { errorMap: customMap, description };74}75class ZodType {76    get description() {77        return this._def.description;78    }79    _getType(input) {80        return (0, util_js_1.getParsedType)(input.data);81    }82    _getOrReturnCtx(input, ctx) {83        return (ctx || {84            common: input.parent.common,85            data: input.data,86            parsedType: (0, util_js_1.getParsedType)(input.data),87            schemaErrorMap: this._def.errorMap,88            path: input.path,89            parent: input.parent,90        });91    }92    _processInputParams(input) {93        return {94            status: new parseUtil_js_1.ParseStatus(),95            ctx: {96                common: input.parent.common,97                data: input.data,98                parsedType: (0, util_js_1.getParsedType)(input.data),99                schemaErrorMap: this._def.errorMap,100                path: input.path,101                parent: input.parent,102            },103        };104    }105    _parseSync(input) {106        const result = this._parse(input);107        if ((0, parseUtil_js_1.isAsync)(result)) {108            throw new Error("Synchronous parse encountered promise.");109        }110        return result;111    }112    _parseAsync(input) {113        const result = this._parse(input);114        return Promise.resolve(result);115    }116    parse(data, params) {117        const result = this.safeParse(data, params);118        if (result.success)119            return result.data;120        throw result.error;121    }122    safeParse(data, params) {123        const ctx = {124            common: {125                issues: [],126                async: params?.async ?? false,127                contextualErrorMap: params?.errorMap,128            },129            path: params?.path || [],130            schemaErrorMap: this._def.errorMap,131            parent: null,132            data,133            parsedType: (0, util_js_1.getParsedType)(data),134        };135        const result = this._parseSync({ data, path: ctx.path, parent: ctx });136        return handleResult(ctx, result);137    }138    "~validate"(data) {139        const ctx = {140            common: {141                issues: [],142                async: !!this["~standard"].async,143            },144            path: [],145            schemaErrorMap: this._def.errorMap,146            parent: null,147            data,148            parsedType: (0, util_js_1.getParsedType)(data),149        };150        if (!this["~standard"].async) {151            try {152                const result = this._parseSync({ data, path: [], parent: ctx });153                return (0, parseUtil_js_1.isValid)(result)154                    ? {155                        value: result.value,156                    }157                    : {158                        issues: ctx.common.issues,159                    };160            }161            catch (err) {162                if (err?.message?.toLowerCase()?.includes("encountered")) {163                    this["~standard"].async = true;164                }165                ctx.common = {166                    issues: [],167                    async: true,168                };169            }170        }171        return this._parseAsync({ data, path: [], parent: ctx }).then((result) => (0, parseUtil_js_1.isValid)(result)172            ? {173                value: result.value,174            }175            : {176                issues: ctx.common.issues,177            });178    }179    async parseAsync(data, params) {180        const result = await this.safeParseAsync(data, params);181        if (result.success)182            return result.data;183        throw result.error;184    }185    async safeParseAsync(data, params) {186        const ctx = {187            common: {188                issues: [],189                contextualErrorMap: params?.errorMap,190                async: true,191            },192            path: params?.path || [],193            schemaErrorMap: this._def.errorMap,194            parent: null,195            data,196            parsedType: (0, util_js_1.getParsedType)(data),197        };198        const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });199        const result = await ((0, parseUtil_js_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));200        return handleResult(ctx, result);201    }202    refine(check, message) {203        const getIssueProperties = (val) => {204            if (typeof message === "string" || typeof message === "undefined") {205                return { message };206            }207            else if (typeof message === "function") {208                return message(val);209            }210            else {211                return message;212            }213        };214        return this._refinement((val, ctx) => {215            const result = check(val);216            const setError = () => ctx.addIssue({217                code: ZodError_js_1.ZodIssueCode.custom,218                ...getIssueProperties(val),219            });220            if (typeof Promise !== "undefined" && result instanceof Promise) {221                return result.then((data) => {222                    if (!data) {223                        setError();224                        return false;225                    }226                    else {227                        return true;228                    }229                });230            }231            if (!result) {232                setError();233                return false;234            }235            else {236                return true;237            }238        });239    }240    refinement(check, refinementData) {241        return this._refinement((val, ctx) => {242            if (!check(val)) {243                ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);244                return false;245            }246            else {247                return true;248            }249        });250    }251    _refinement(refinement) {252        return new ZodEffects({253            schema: this,254            typeName: ZodFirstPartyTypeKind.ZodEffects,255            effect: { type: "refinement", refinement },256        });257    }258    superRefine(refinement) {259        return this._refinement(refinement);260    }261    constructor(def) {262        /** Alias of safeParseAsync */263        this.spa = this.safeParseAsync;264        this._def = def;265        this.parse = this.parse.bind(this);266        this.safeParse = this.safeParse.bind(this);267        this.parseAsync = this.parseAsync.bind(this);268        this.safeParseAsync = this.safeParseAsync.bind(this);269        this.spa = this.spa.bind(this);270        this.refine = this.refine.bind(this);271        this.refinement = this.refinement.bind(this);272        this.superRefine = this.superRefine.bind(this);273        this.optional = this.optional.bind(this);274        this.nullable = this.nullable.bind(this);275        this.nullish = this.nullish.bind(this);276        this.array = this.array.bind(this);277        this.promise = this.promise.bind(this);278        this.or = this.or.bind(this);279        this.and = this.and.bind(this);280        this.transform = this.transform.bind(this);281        this.brand = this.brand.bind(this);282        this.default = this.default.bind(this);283        this.catch = this.catch.bind(this);284        this.describe = this.describe.bind(this);285        this.pipe = this.pipe.bind(this);286        this.readonly = this.readonly.bind(this);287        this.isNullable = this.isNullable.bind(this);288        this.isOptional = this.isOptional.bind(this);289        this["~standard"] = {290            version: 1,291            vendor: "zod",292            validate: (data) => this["~validate"](data),293        };294    }295    optional() {296        return ZodOptional.create(this, this._def);297    }298    nullable() {299        return ZodNullable.create(this, this._def);300    }301    nullish() {302        return this.nullable().optional();303    }304    array() {305        return ZodArray.create(this);306    }307    promise() {308        return ZodPromise.create(this, this._def);309    }310    or(option) {311        return ZodUnion.create([this, option], this._def);312    }313    and(incoming) {314        return ZodIntersection.create(this, incoming, this._def);315    }316    transform(transform) {317        return new ZodEffects({318            ...processCreateParams(this._def),319            schema: this,320            typeName: ZodFirstPartyTypeKind.ZodEffects,321            effect: { type: "transform", transform },322        });323    }324    default(def) {325        const defaultValueFunc = typeof def === "function" ? def : () => def;326        return new ZodDefault({327            ...processCreateParams(this._def),328            innerType: this,329            defaultValue: defaultValueFunc,330            typeName: ZodFirstPartyTypeKind.ZodDefault,331        });332    }333    brand() {334        return new ZodBranded({335            typeName: ZodFirstPartyTypeKind.ZodBranded,336            type: this,337            ...processCreateParams(this._def),338        });339    }340    catch(def) {341        const catchValueFunc = typeof def === "function" ? def : () => def;342        return new ZodCatch({343            ...processCreateParams(this._def),344            innerType: this,345            catchValue: catchValueFunc,346            typeName: ZodFirstPartyTypeKind.ZodCatch,347        });348    }349    describe(description) {350        const This = this.constructor;351        return new This({352            ...this._def,353            description,354        });355    }356    pipe(target) {357        return ZodPipeline.create(this, target);358    }359    readonly() {360        return ZodReadonly.create(this);361    }362    isOptional() {363        return this.safeParse(undefined).success;364    }365    isNullable() {366        return this.safeParse(null).success;367    }368}369exports.ZodType = ZodType;370exports.Schema = ZodType;371exports.ZodSchema = ZodType;372const cuidRegex = /^c[^\s-]{8,}$/i;373const cuid2Regex = /^[0-9a-z]+$/;374const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;375// const uuidRegex =376//   /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;377const uuidRegex = /^[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;378const nanoidRegex = /^[a-z0-9_-]{21}$/i;379const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;380const durationRegex = /^[-+]?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)?)??$/;381// from https://stackoverflow.com/a/46181/1550155382// old version: too slow, didn't support unicode383// const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;384//old email regex385// const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;386// eslint-disable-next-line387// const emailRegex =388//   /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;389// const emailRegex =390//   /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;391// const emailRegex =392//   /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;393const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;394// const emailRegex =395//   /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;396// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression397const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;398let emojiRegex;399// faster, simpler, safer400const ipv4Regex = /^(?:(?: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])$/;401const ipv4CidrRegex = /^(?:(?: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])$/;402// const ipv6Regex =403// /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;404const ipv6Regex = /^(([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]))$/;405const ipv6CidrRegex = /^(([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])$/;406// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript407const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;408// https://base64.guru/standards/base64url409const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;410// simple411// const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;412// no leap year validation413// const dateRegexSource = `\\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\\d|2\\d))`;414// with leap year validation415const dateRegexSource = `((\\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])))`;416const dateRegex = new RegExp(`^${dateRegexSource}$`);417function timeRegexSource(args) {418    let secondsRegexSource = `[0-5]\\d`;419    if (args.precision) {420        secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;421    }422    else if (args.precision == null) {423        secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;424    }425    const secondsQuantifier = args.precision ? "+" : "?"; // require seconds if precision is nonzero426    return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;427}428function timeRegex(args) {429    return new RegExp(`^${timeRegexSource(args)}$`);430}431// Adapted from https://stackoverflow.com/a/3143231432function datetimeRegex(args) {433    let regex = `${dateRegexSource}T${timeRegexSource(args)}`;434    const opts = [];435    opts.push(args.local ? `Z?` : `Z`);436    if (args.offset)437        opts.push(`([+-]\\d{2}:?\\d{2})`);438    regex = `${regex}(${opts.join("|")})`;439    return new RegExp(`^${regex}$`);440}441function isValidIP(ip, version) {442    if ((version === "v4" || !version) && ipv4Regex.test(ip)) {443        return true;444    }445    if ((version === "v6" || !version) && ipv6Regex.test(ip)) {446        return true;447    }448    return false;449}450function isValidJWT(jwt, alg) {451    if (!jwtRegex.test(jwt))452        return false;453    try {454        const [header] = jwt.split(".");455        if (!header)456            return false;457        // Convert base64url to base64458        const base64 = header459            .replace(/-/g, "+")460            .replace(/_/g, "/")461            .padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");462        // @ts-ignore463        const decoded = JSON.parse(atob(base64));464        if (typeof decoded !== "object" || decoded === null)465            return false;466        if ("typ" in decoded && decoded?.typ !== "JWT")467            return false;468        if (!decoded.alg)469            return false;470        if (alg && decoded.alg !== alg)471            return false;472        return true;473    }474    catch {475        return false;476    }477}478function isValidCidr(ip, version) {479    if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {480        return true;481    }482    if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {483        return true;484    }485    return false;486}487class ZodString extends ZodType {488    _parse(input) {489        if (this._def.coerce) {490            input.data = String(input.data);491        }492        const parsedType = this._getType(input);493        if (parsedType !== util_js_1.ZodParsedType.string) {494            const ctx = this._getOrReturnCtx(input);495            (0, parseUtil_js_1.addIssueToContext)(ctx, {496                code: ZodError_js_1.ZodIssueCode.invalid_type,497                expected: util_js_1.ZodParsedType.string,498                received: ctx.parsedType,499            });500            return parseUtil_js_1.INVALID;501        }502        const status = new parseUtil_js_1.ParseStatus();503        let ctx = undefined;504        for (const check of this._def.checks) {505            if (check.kind === "min") {506                if (input.data.length < check.value) {507                    ctx = this._getOrReturnCtx(input, ctx);508                    (0, parseUtil_js_1.addIssueToContext)(ctx, {509                        code: ZodError_js_1.ZodIssueCode.too_small,510                        minimum: check.value,511                        type: "string",512                        inclusive: true,513                        exact: false,514                        message: check.message,515                    });516                    status.dirty();517                }518            }519            else if (check.kind === "max") {520                if (input.data.length > check.value) {521                    ctx = this._getOrReturnCtx(input, ctx);522                    (0, parseUtil_js_1.addIssueToContext)(ctx, {523                        code: ZodError_js_1.ZodIssueCode.too_big,524                        maximum: check.value,525                        type: "string",526                        inclusive: true,527                        exact: false,528                        message: check.message,529                    });530                    status.dirty();531                }532            }533            else if (check.kind === "length") {534                const tooBig = input.data.length > check.value;535                const tooSmall = input.data.length < check.value;536                if (tooBig || tooSmall) {537                    ctx = this._getOrReturnCtx(input, ctx);538                    if (tooBig) {539                        (0, parseUtil_js_1.addIssueToContext)(ctx, {540                            code: ZodError_js_1.ZodIssueCode.too_big,541                            maximum: check.value,542                            type: "string",543                            inclusive: true,544                            exact: true,545                            message: check.message,546                        });547                    }548                    else if (tooSmall) {549                        (0, parseUtil_js_1.addIssueToContext)(ctx, {550                            code: ZodError_js_1.ZodIssueCode.too_small,551                            minimum: check.value,552                            type: "string",553                            inclusive: true,554                            exact: true,555                            message: check.message,556                        });557                    }558                    status.dirty();559                }560            }561            else if (check.kind === "email") {562                if (!emailRegex.test(input.data)) {563                    ctx = this._getOrReturnCtx(input, ctx);564                    (0, parseUtil_js_1.addIssueToContext)(ctx, {565                        validation: "email",566                        code: ZodError_js_1.ZodIssueCode.invalid_string,567                        message: check.message,568                    });569                    status.dirty();570                }571            }572            else if (check.kind === "emoji") {573                if (!emojiRegex) {574                    emojiRegex = new RegExp(_emojiRegex, "u");575                }576                if (!emojiRegex.test(input.data)) {577                    ctx = this._getOrReturnCtx(input, ctx);578                    (0, parseUtil_js_1.addIssueToContext)(ctx, {579                        validation: "emoji",580                        code: ZodError_js_1.ZodIssueCode.invalid_string,581                        message: check.message,582                    });583                    status.dirty();584                }585            }586            else if (check.kind === "uuid") {587                if (!uuidRegex.test(input.data)) {588                    ctx = this._getOrReturnCtx(input, ctx);589                    (0, parseUtil_js_1.addIssueToContext)(ctx, {590                        validation: "uuid",591                        code: ZodError_js_1.ZodIssueCode.invalid_string,592                        message: check.message,593                    });594                    status.dirty();595                }596            }597            else if (check.kind === "nanoid") {598                if (!nanoidRegex.test(input.data)) {599                    ctx = this._getOrReturnCtx(input, ctx);600                    (0, parseUtil_js_1.addIssueToContext)(ctx, {601                        validation: "nanoid",602                        code: ZodError_js_1.ZodIssueCode.invalid_string,603                        message: check.message,604                    });605                    status.dirty();606                }607            }608            else if (check.kind === "cuid") {609                if (!cuidRegex.test(input.data)) {610                    ctx = this._getOrReturnCtx(input, ctx);611                    (0, parseUtil_js_1.addIssueToContext)(ctx, {612                        validation: "cuid",613                        code: ZodError_js_1.ZodIssueCode.invalid_string,614                        message: check.message,615                    });616                    status.dirty();617                }618            }619            else if (check.kind === "cuid2") {620                if (!cuid2Regex.test(input.data)) {621                    ctx = this._getOrReturnCtx(input, ctx);622                    (0, parseUtil_js_1.addIssueToContext)(ctx, {623                        validation: "cuid2",624                        code: ZodError_js_1.ZodIssueCode.invalid_string,625                        message: check.message,626                    });627                    status.dirty();628                }629            }630            else if (check.kind === "ulid") {631                if (!ulidRegex.test(input.data)) {632                    ctx = this._getOrReturnCtx(input, ctx);633                    (0, parseUtil_js_1.addIssueToContext)(ctx, {634                        validation: "ulid",635                        code: ZodError_js_1.ZodIssueCode.invalid_string,636                        message: check.message,637                    });638                    status.dirty();639                }640            }641            else if (check.kind === "url") {642                try {643                    // @ts-ignore644                    new URL(input.data);645                }646                catch {647                    ctx = this._getOrReturnCtx(input, ctx);648                    (0, parseUtil_js_1.addIssueToContext)(ctx, {649                        validation: "url",650                        code: ZodError_js_1.ZodIssueCode.invalid_string,651                        message: check.message,652                    });653                    status.dirty();654                }655            }656            else if (check.kind === "regex") {657                check.regex.lastIndex = 0;658                const testResult = check.regex.test(input.data);659                if (!testResult) {660                    ctx = this._getOrReturnCtx(input, ctx);661                    (0, parseUtil_js_1.addIssueToContext)(ctx, {662                        validation: "regex",663                        code: ZodError_js_1.ZodIssueCode.invalid_string,664                        message: check.message,665                    });666                    status.dirty();667                }668            }669            else if (check.kind === "trim") {670                input.data = input.data.trim();671            }672            else if (check.kind === "includes") {673                if (!input.data.includes(check.value, check.position)) {674                    ctx = this._getOrReturnCtx(input, ctx);675                    (0, parseUtil_js_1.addIssueToContext)(ctx, {676                        code: ZodError_js_1.ZodIssueCode.invalid_string,677                        validation: { includes: check.value, position: check.position },678                        message: check.message,679                    });680                    status.dirty();681                }682            }683            else if (check.kind === "toLowerCase") {684                input.data = input.data.toLowerCase();685            }686            else if (check.kind === "toUpperCase") {687                input.data = input.data.toUpperCase();688            }689            else if (check.kind === "startsWith") {690                if (!input.data.startsWith(check.value)) {691                    ctx = this._getOrReturnCtx(input, ctx);692                    (0, parseUtil_js_1.addIssueToContext)(ctx, {693                        code: ZodError_js_1.ZodIssueCode.invalid_string,694                        validation: { startsWith: check.value },695                        message: check.message,696                    });697                    status.dirty();698                }699            }700            else if (check.kind === "endsWith") {701                if (!input.data.endsWith(check.value)) {702                    ctx = this._getOrReturnCtx(input, ctx);703                    (0, parseUtil_js_1.addIssueToContext)(ctx, {704                        code: ZodError_js_1.ZodIssueCode.invalid_string,705                        validation: { endsWith: check.value },706                        message: check.message,707                    });708                    status.dirty();709                }710            }711            else if (check.kind === "datetime") {712                const regex = datetimeRegex(check);713                if (!regex.test(input.data)) {714                    ctx = this._getOrReturnCtx(input, ctx);715                    (0, parseUtil_js_1.addIssueToContext)(ctx, {716                        code: ZodError_js_1.ZodIssueCode.invalid_string,717                        validation: "datetime",718                        message: check.message,719                    });720                    status.dirty();721                }722            }723            else if (check.kind === "date") {724                const regex = dateRegex;725                if (!regex.test(input.data)) {726                    ctx = this._getOrReturnCtx(input, ctx);727                    (0, parseUtil_js_1.addIssueToContext)(ctx, {728                        code: ZodError_js_1.ZodIssueCode.invalid_string,729                        validation: "date",730                        message: check.message,731                    });732                    status.dirty();733                }734            }735            else if (check.kind === "time") {736                const regex = timeRegex(check);737                if (!regex.test(input.data)) {738                    ctx = this._getOrReturnCtx(input, ctx);739                    (0, parseUtil_js_1.addIssueToContext)(ctx, {740                        code: ZodError_js_1.ZodIssueCode.invalid_string,741                        validation: "time",742                        message: check.message,743                    });744                    status.dirty();745                }746            }747            else if (check.kind === "duration") {748                if (!durationRegex.test(input.data)) {749                    ctx = this._getOrReturnCtx(input, ctx);750                    (0, parseUtil_js_1.addIssueToContext)(ctx, {751                        validation: "duration",752                        code: ZodError_js_1.ZodIssueCode.invalid_string,753                        message: check.message,754                    });755                    status.dirty();756                }757            }758            else if (check.kind === "ip") {759                if (!isValidIP(input.data, check.version)) {760                    ctx = this._getOrReturnCtx(input, ctx);761                    (0, parseUtil_js_1.addIssueToContext)(ctx, {762                        validation: "ip",763                        code: ZodError_js_1.ZodIssueCode.invalid_string,764                        message: check.message,765                    });766                    status.dirty();767                }768            }769            else if (check.kind === "jwt") {770                if (!isValidJWT(input.data, check.alg)) {771                    ctx = this._getOrReturnCtx(input, ctx);772                    (0, parseUtil_js_1.addIssueToContext)(ctx, {773                        validation: "jwt",774                        code: ZodError_js_1.ZodIssueCode.invalid_string,775                        message: check.message,776                    });777                    status.dirty();778                }779            }780            else if (check.kind === "cidr") {781                if (!isValidCidr(input.data, check.version)) {782                    ctx = this._getOrReturnCtx(input, ctx);783                    (0, parseUtil_js_1.addIssueToContext)(ctx, {784                        validation: "cidr",785                        code: ZodError_js_1.ZodIssueCode.invalid_string,786                        message: check.message,787                    });788                    status.dirty();789                }790            }791            else if (check.kind === "base64") {792                if (!base64Regex.test(input.data)) {793                    ctx = this._getOrReturnCtx(input, ctx);794                    (0, parseUtil_js_1.addIssueToContext)(ctx, {795                        validation: "base64",796                        code: ZodError_js_1.ZodIssueCode.invalid_string,797                        message: check.message,798                    });799                    status.dirty();800                }801            }802            else if (check.kind === "base64url") {803                if (!base64urlRegex.test(input.data)) {804                    ctx = this._getOrReturnCtx(input, ctx);805                    (0, parseUtil_js_1.addIssueToContext)(ctx, {806                        validation: "base64url",807                        code: ZodError_js_1.ZodIssueCode.invalid_string,808                        message: check.message,809                    });810                    status.dirty();811                }812            }813            else {814                util_js_1.util.assertNever(check);815            }816        }817        return { status: status.value, value: input.data };818    }819    _regex(regex, validation, message) {820        return this.refinement((data) => regex.test(data), {821            validation,822            code: ZodError_js_1.ZodIssueCode.invalid_string,823            ...errorUtil_js_1.errorUtil.errToObj(message),824        });825    }826    _addCheck(check) {827        return new ZodString({828            ...this._def,829            checks: [...this._def.checks, check],830        });831    }832    email(message) {833        return this._addCheck({ kind: "email", ...errorUtil_js_1.errorUtil.errToObj(message) });834    }835    url(message) {836        return this._addCheck({ kind: "url", ...errorUtil_js_1.errorUtil.errToObj(message) });837    }838    emoji(message) {839        return this._addCheck({ kind: "emoji", ...errorUtil_js_1.errorUtil.errToObj(message) });840    }841    uuid(message) {842        return this._addCheck({ kind: "uuid", ...errorUtil_js_1.errorUtil.errToObj(message) });843    }844    nanoid(message) {845        return this._addCheck({ kind: "nanoid", ...errorUtil_js_1.errorUtil.errToObj(message) });846    }847    cuid(message) {848        return this._addCheck({ kind: "cuid", ...errorUtil_js_1.errorUtil.errToObj(message) });849    }850    cuid2(message) {851        return this._addCheck({ kind: "cuid2", ...errorUtil_js_1.errorUtil.errToObj(message) });852    }853    ulid(message) {854        return this._addCheck({ kind: "ulid", ...errorUtil_js_1.errorUtil.errToObj(message) });855    }856    base64(message) {857        return this._addCheck({ kind: "base64", ...errorUtil_js_1.errorUtil.errToObj(message) });858    }859    base64url(message) {860        // base64url encoding is a modification of base64 that can safely be used in URLs and filenames861        return this._addCheck({862            kind: "base64url",863            ...errorUtil_js_1.errorUtil.errToObj(message),864        });865    }866    jwt(options) {867        return this._addCheck({ kind: "jwt", ...errorUtil_js_1.errorUtil.errToObj(options) });868    }869    ip(options) {870        return this._addCheck({ kind: "ip", ...errorUtil_js_1.errorUtil.errToObj(options) });871    }872    cidr(options) {873        return this._addCheck({ kind: "cidr", ...errorUtil_js_1.errorUtil.errToObj(options) });874    }875    datetime(options) {876        if (typeof options === "string") {877            return this._addCheck({878                kind: "datetime",879                precision: null,880                offset: false,881                local: false,882                message: options,883            });884        }885        return this._addCheck({886            kind: "datetime",887            precision: typeof options?.precision === "undefined" ? null : options?.precision,888            offset: options?.offset ?? false,889            local: options?.local ?? false,890            ...errorUtil_js_1.errorUtil.errToObj(options?.message),891        });892    }893    date(message) {894        return this._addCheck({ kind: "date", message });895    }896    time(options) {897        if (typeof options === "string") {898            return this._addCheck({899                kind: "time",900                precision: null,901                message: options,902            });903        }904        return this._addCheck({905            kind: "time",906            precision: typeof options?.precision === "undefined" ? null : options?.precision,907            ...errorUtil_js_1.errorUtil.errToObj(options?.message),908        });909    }910    duration(message) {911        return this._addCheck({ kind: "duration", ...errorUtil_js_1.errorUtil.errToObj(message) });912    }913    regex(regex, message) {914        return this._addCheck({915            kind: "regex",916            regex: regex,917            ...errorUtil_js_1.errorUtil.errToObj(message),918        });919    }920    includes(value, options) {921        return this._addCheck({922            kind: "includes",923            value: value,924            position: options?.position,925            ...errorUtil_js_1.errorUtil.errToObj(options?.message),926        });927    }928    startsWith(value, message) {929        return this._addCheck({930            kind: "startsWith",931            value: value,932            ...errorUtil_js_1.errorUtil.errToObj(message),933        });934    }935    endsWith(value, message) {936        return this._addCheck({937            kind: "endsWith",938            value: value,939            ...errorUtil_js_1.errorUtil.errToObj(message),940        });941    }942    min(minLength, message) {943        return this._addCheck({944            kind: "min",945            value: minLength,946            ...errorUtil_js_1.errorUtil.errToObj(message),947        });948    }949    max(maxLength, message) {950        return this._addCheck({951            kind: "max",952            value: maxLength,953            ...errorUtil_js_1.errorUtil.errToObj(message),954        });955    }956    length(len, message) {957        return this._addCheck({958            kind: "length",959            value: len,960            ...errorUtil_js_1.errorUtil.errToObj(message),961        });962    }963    /**964     * Equivalent to `.min(1)`965     */966    nonempty(message) {967        return this.min(1, errorUtil_js_1.errorUtil.errToObj(message));968    }969    trim() {970        return new ZodString({971            ...this._def,972            checks: [...this._def.checks, { kind: "trim" }],973        });974    }975    toLowerCase() {976        return new ZodString({977            ...this._def,978            checks: [...this._def.checks, { kind: "toLowerCase" }],979        });980    }981    toUpperCase() {982        return new ZodString({983            ...this._def,984            checks: [...this._def.checks, { kind: "toUpperCase" }],985        });986    }987    get isDatetime() {988        return !!this._def.checks.find((ch) => ch.kind === "datetime");989    }990    get isDate() {991        return !!this._def.checks.find((ch) => ch.kind === "date");992    }993    get isTime() {994        return !!this._def.checks.find((ch) => ch.kind === "time");995    }996    get isDuration() {997        return !!this._def.checks.find((ch) => ch.kind === "duration");998    }999    get isEmail() {1000        return !!this._def.checks.find((ch) => ch.kind === "email");1001    }1002    get isURL() {1003        return !!this._def.checks.find((ch) => ch.kind === "url");1004    }1005    get isEmoji() {1006        return !!this._def.checks.find((ch) => ch.kind === "emoji");1007    }1008    get isUUID() {1009        return !!this._def.checks.find((ch) => ch.kind === "uuid");1010    }1011    get isNANOID() {1012        return !!this._def.checks.find((ch) => ch.kind === "nanoid");1013    }1014    get isCUID() {1015        return !!this._def.checks.find((ch) => ch.kind === "cuid");1016    }1017    get isCUID2() {1018        return !!this._def.checks.find((ch) => ch.kind === "cuid2");1019    }1020    get isULID() {1021        return !!this._def.checks.find((ch) => ch.kind === "ulid");1022    }1023    get isIP() {1024        return !!this._def.checks.find((ch) => ch.kind === "ip");1025    }1026    get isCIDR() {1027        return !!this._def.checks.find((ch) => ch.kind === "cidr");1028    }1029    get isBase64() {1030        return !!this._def.checks.find((ch) => ch.kind === "base64");1031    }1032    get isBase64url() {1033        // base64url encoding is a modification of base64 that can safely be used in URLs and filenames1034        return !!this._def.checks.find((ch) => ch.kind === "base64url");1035    }1036    get minLength() {1037        let min = null;1038        for (const ch of this._def.checks) {1039            if (ch.kind === "min") {1040                if (min === null || ch.value > min)1041                    min = ch.value;1042            }1043        }1044        return min;1045    }1046    get maxLength() {1047        let max = null;1048        for (const ch of this._def.checks) {1049            if (ch.kind === "max") {1050                if (max === null || ch.value < max)1051                    max = ch.value;1052            }1053        }1054        return max;1055    }1056}1057exports.ZodString = ZodString;1058ZodString.create = (params) => {1059    return new ZodString({1060        checks: [],1061        typeName: ZodFirstPartyTypeKind.ZodString,1062        coerce: params?.coerce ?? false,1063        ...processCreateParams(params),1064    });1065};1066// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#317110341067function floatSafeRemainder(val, step) {1068    const valDecCount = (val.toString().split(".")[1] || "").length;1069    const stepDecCount = (step.toString().split(".")[1] || "").length;1070    const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;1071    const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));1072    const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));1073    return (valInt % stepInt) / 10 ** decCount;1074}1075class ZodNumber extends ZodType {1076    constructor() {1077        super(...arguments);1078        this.min = this.gte;1079        this.max = this.lte;1080        this.step = this.multipleOf;1081    }1082    _parse(input) {1083        if (this._def.coerce) {1084            input.data = Number(input.data);1085        }1086        const parsedType = this._getType(input);1087        if (parsedType !== util_js_1.ZodParsedType.number) {1088            const ctx = this._getOrReturnCtx(input);1089            (0, parseUtil_js_1.addIssueToContext)(ctx, {1090                code: ZodError_js_1.ZodIssueCode.invalid_type,1091                expected: util_js_1.ZodParsedType.number,1092                received: ctx.parsedType,1093            });1094            return parseUtil_js_1.INVALID;1095        }1096        let ctx = undefined;1097        const status = new parseUtil_js_1.ParseStatus();1098        for (const check of this._def.checks) {1099            if (check.kind === "int") {1100                if (!util_js_1.util.isInteger(input.data)) {1101                    ctx = this._getOrReturnCtx(input, ctx);1102                    (0, parseUtil_js_1.addIssueToContext)(ctx, {1103                        code: ZodError_js_1.ZodIssueCode.invalid_type,1104                        expected: "integer",1105                        received: "float",1106                        message: check.message,1107                    });1108                    status.dirty();1109                }1110            }1111            else if (check.kind === "min") {1112                const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;1113                if (tooSmall) {1114                    ctx = this._getOrReturnCtx(input, ctx);1115                    (0, parseUtil_js_1.addIssueToContext)(ctx, {1116                        code: ZodError_js_1.ZodIssueCode.too_small,1117                        minimum: check.value,1118                        type: "number",1119                        inclusive: check.inclusive,1120                        exact: false,1121                        message: check.message,1122                    });1123                    status.dirty();1124                }1125            }1126            else if (check.kind === "max") {1127                const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;1128                if (tooBig) {1129                    ctx = this._getOrReturnCtx(input, ctx);1130                    (0, parseUtil_js_1.addIssueToContext)(ctx, {1131                        code: ZodError_js_1.ZodIssueCode.too_big,1132                        maximum: check.value,1133                        type: "number",1134                        inclusive: check.inclusive,1135                        exact: false,1136                        message: check.message,1137                    });1138                    status.dirty();1139                }1140            }1141            else if (check.kind === "multipleOf") {1142                if (floatSafeRemainder(input.data, check.value) !== 0) {1143                    ctx = this._getOrReturnCtx(input, ctx);1144                    (0, parseUtil_js_1.addIssueToContext)(ctx, {1145                        code: ZodError_js_1.ZodIssueCode.not_multiple_of,1146                        multipleOf: check.value,1147                        message: check.message,1148                    });1149                    status.dirty();1150                }1151            }1152            else if (check.kind === "finite") {1153                if (!Number.isFinite(input.data)) {1154                    ctx = this._getOrReturnCtx(input, ctx);1155                    (0, parseUtil_js_1.addIssueToContext)(ctx, {1156                        code: ZodError_js_1.ZodIssueCode.not_finite,1157                        message: check.message,1158                    });1159                    status.dirty();1160                }1161            }1162            else {1163                util_js_1.util.assertNever(check);1164            }1165        }1166        return { status: status.value, value: input.data };1167    }1168    gte(value, message) {1169        return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));1170    }1171    gt(value, message) {1172        return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));1173    }1174    lte(value, message) {1175        return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));1176    }1177    lt(value, message) {1178        return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));1179    }1180    setLimit(kind, value, inclusive, message) {1181        return new ZodNumber({1182            ...this._def,1183            checks: [1184                ...this._def.checks,1185                {1186                    kind,1187                    value,1188                    inclusive,1189                    message: errorUtil_js_1.errorUtil.toString(message),1190                },1191            ],1192        });1193    }1194    _addCheck(check) {1195        return new ZodNumber({1196            ...this._def,1197            checks: [...this._def.checks, check],1198        });1199    }1200    int(message) {

Showing the first 1,200 of 3778 lines. Download the file for the rest.