Merge pull request #769 from actions/dependabot/npm_and_yarn/zod-3.23.8
Bump zod from 3.22.4 to 3.23.8
This commit is contained in:
343
dist/index.js
generated
vendored
343
dist/index.js
generated
vendored
@@ -45928,6 +45928,11 @@ class ZodError extends Error {
|
||||
processError(this);
|
||||
return fieldErrors;
|
||||
}
|
||||
static assert(value) {
|
||||
if (!(value instanceof ZodError)) {
|
||||
throw new Error(`Not a ZodError: ${value}`);
|
||||
}
|
||||
}
|
||||
toString() {
|
||||
return this.message;
|
||||
}
|
||||
@@ -46050,6 +46055,13 @@ const makeIssue = (params) => {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
};
|
||||
if (issueData.message !== undefined) {
|
||||
return {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
message: issueData.message,
|
||||
};
|
||||
}
|
||||
let errorMessage = "";
|
||||
const maps = errorMaps
|
||||
.filter((m) => !!m)
|
||||
@@ -46061,12 +46073,13 @@ const makeIssue = (params) => {
|
||||
return {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
message: issueData.message || errorMessage,
|
||||
message: errorMessage,
|
||||
};
|
||||
};
|
||||
exports.makeIssue = makeIssue;
|
||||
exports.EMPTY_PATH = [];
|
||||
function addIssueToContext(ctx, issueData) {
|
||||
const overrideMap = (0, errors_1.getErrorMap)();
|
||||
const issue = (0, exports.makeIssue)({
|
||||
issueData: issueData,
|
||||
data: ctx.data,
|
||||
@@ -46074,8 +46087,8 @@ function addIssueToContext(ctx, issueData) {
|
||||
errorMaps: [
|
||||
ctx.common.contextualErrorMap,
|
||||
ctx.schemaErrorMap,
|
||||
(0, errors_1.getErrorMap)(),
|
||||
en_1.default, // then global default map
|
||||
overrideMap,
|
||||
overrideMap === en_1.default ? undefined : en_1.default, // then global default map
|
||||
].filter((x) => !!x),
|
||||
});
|
||||
ctx.common.issues.push(issue);
|
||||
@@ -46107,9 +46120,11 @@ class ParseStatus {
|
||||
static async mergeObjectAsync(status, pairs) {
|
||||
const syncPairs = [];
|
||||
for (const pair of pairs) {
|
||||
const key = await pair.key;
|
||||
const value = await pair.value;
|
||||
syncPairs.push({
|
||||
key: await pair.key,
|
||||
value: await pair.value,
|
||||
key,
|
||||
value,
|
||||
});
|
||||
}
|
||||
return ParseStatus.mergeObjectSync(status, syncPairs);
|
||||
@@ -46489,13 +46504,25 @@ exports["default"] = errorMap;
|
||||
/***/ }),
|
||||
|
||||
/***/ 9335:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
};
|
||||
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = 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;
|
||||
exports.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 = exports.discriminatedUnion = void 0;
|
||||
exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = 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.datetimeRegex = exports.ZodType = void 0;
|
||||
exports.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 = exports.discriminatedUnion = exports.date = void 0;
|
||||
const errors_1 = __nccwpck_require__(9566);
|
||||
const errorUtil_1 = __nccwpck_require__(2513);
|
||||
const parseUtil_1 = __nccwpck_require__(8088);
|
||||
@@ -46551,12 +46578,17 @@ function processCreateParams(params) {
|
||||
if (errorMap)
|
||||
return { errorMap: errorMap, description };
|
||||
const customMap = (iss, ctx) => {
|
||||
var _a, _b;
|
||||
const { message } = params;
|
||||
if (iss.code === "invalid_enum_value") {
|
||||
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
||||
}
|
||||
if (typeof ctx.data === "undefined") {
|
||||
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
||||
}
|
||||
if (iss.code !== "invalid_type")
|
||||
return { message: ctx.defaultError };
|
||||
if (typeof ctx.data === "undefined") {
|
||||
return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
|
||||
}
|
||||
return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
|
||||
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
||||
};
|
||||
return { errorMap: customMap, description };
|
||||
}
|
||||
@@ -46817,11 +46849,13 @@ exports.ZodType = ZodType;
|
||||
exports.Schema = ZodType;
|
||||
exports.ZodSchema = ZodType;
|
||||
const cuidRegex = /^c[^\s-]{8,}$/i;
|
||||
const cuid2Regex = /^[a-z][a-z0-9]*$/;
|
||||
const cuid2Regex = /^[0-9a-z]+$/;
|
||||
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
||||
// const uuidRegex =
|
||||
// /^([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;
|
||||
const 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;
|
||||
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
||||
const 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)?)??$/;
|
||||
// from https://stackoverflow.com/a/46181/1550155
|
||||
// old version: too slow, didn't support unicode
|
||||
// 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;
|
||||
@@ -46834,41 +46868,49 @@ const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-
|
||||
// /^[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])?)*$/;
|
||||
// const emailRegex =
|
||||
// /^(?:[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;
|
||||
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
||||
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
||||
// const emailRegex =
|
||||
// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
|
||||
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
||||
const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
||||
let emojiRegex;
|
||||
const ipv4Regex = /^(((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}))$/;
|
||||
// faster, simpler, safer
|
||||
const 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])$/;
|
||||
const ipv6Regex = /^(([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})))$/;
|
||||
// Adapted from https://stackoverflow.com/a/3143231
|
||||
const datetimeRegex = (args) => {
|
||||
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
||||
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
||||
// simple
|
||||
// const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;
|
||||
// no leap year validation
|
||||
// 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))`;
|
||||
// with leap year validation
|
||||
const 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])))`;
|
||||
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
||||
function timeRegexSource(args) {
|
||||
// let regex = `\\d{2}:\\d{2}:\\d{2}`;
|
||||
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
||||
if (args.precision) {
|
||||
if (args.offset) {
|
||||
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
||||
}
|
||||
else {
|
||||
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
||||
}
|
||||
regex = `${regex}\\.\\d{${args.precision}}`;
|
||||
}
|
||||
else if (args.precision === 0) {
|
||||
if (args.offset) {
|
||||
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
||||
}
|
||||
else {
|
||||
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
||||
}
|
||||
else if (args.precision == null) {
|
||||
regex = `${regex}(\\.\\d+)?`;
|
||||
}
|
||||
else {
|
||||
if (args.offset) {
|
||||
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
||||
}
|
||||
else {
|
||||
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
||||
}
|
||||
}
|
||||
};
|
||||
return regex;
|
||||
}
|
||||
function timeRegex(args) {
|
||||
return new RegExp(`^${timeRegexSource(args)}$`);
|
||||
}
|
||||
// Adapted from https://stackoverflow.com/a/3143231
|
||||
function datetimeRegex(args) {
|
||||
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
||||
const opts = [];
|
||||
opts.push(args.local ? `Z?` : `Z`);
|
||||
if (args.offset)
|
||||
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
||||
regex = `${regex}(${opts.join("|")})`;
|
||||
return new RegExp(`^${regex}$`);
|
||||
}
|
||||
exports.datetimeRegex = datetimeRegex;
|
||||
function isValidIP(ip, version) {
|
||||
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
||||
return true;
|
||||
@@ -46890,9 +46932,7 @@ class ZodString extends ZodType {
|
||||
code: ZodError_1.ZodIssueCode.invalid_type,
|
||||
expected: util_1.ZodParsedType.string,
|
||||
received: ctx.parsedType,
|
||||
}
|
||||
//
|
||||
);
|
||||
});
|
||||
return parseUtil_1.INVALID;
|
||||
}
|
||||
const status = new parseUtil_1.ParseStatus();
|
||||
@@ -46990,6 +47030,17 @@ class ZodString extends ZodType {
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "nanoid") {
|
||||
if (!nanoidRegex.test(input.data)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
validation: "nanoid",
|
||||
code: ZodError_1.ZodIssueCode.invalid_string,
|
||||
message: check.message,
|
||||
});
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "cuid") {
|
||||
if (!cuidRegex.test(input.data)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
@@ -47104,6 +47155,41 @@ class ZodString extends ZodType {
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "date") {
|
||||
const regex = dateRegex;
|
||||
if (!regex.test(input.data)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
code: ZodError_1.ZodIssueCode.invalid_string,
|
||||
validation: "date",
|
||||
message: check.message,
|
||||
});
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "time") {
|
||||
const regex = timeRegex(check);
|
||||
if (!regex.test(input.data)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
code: ZodError_1.ZodIssueCode.invalid_string,
|
||||
validation: "time",
|
||||
message: check.message,
|
||||
});
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "duration") {
|
||||
if (!durationRegex.test(input.data)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
validation: "duration",
|
||||
code: ZodError_1.ZodIssueCode.invalid_string,
|
||||
message: check.message,
|
||||
});
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "ip") {
|
||||
if (!isValidIP(input.data, check.version)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
@@ -47115,6 +47201,17 @@ class ZodString extends ZodType {
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else if (check.kind === "base64") {
|
||||
if (!base64Regex.test(input.data)) {
|
||||
ctx = this._getOrReturnCtx(input, ctx);
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
validation: "base64",
|
||||
code: ZodError_1.ZodIssueCode.invalid_string,
|
||||
message: check.message,
|
||||
});
|
||||
status.dirty();
|
||||
}
|
||||
}
|
||||
else {
|
||||
util_1.util.assertNever(check);
|
||||
}
|
||||
@@ -47146,6 +47243,9 @@ class ZodString extends ZodType {
|
||||
uuid(message) {
|
||||
return this._addCheck({ kind: "uuid", ...errorUtil_1.errorUtil.errToObj(message) });
|
||||
}
|
||||
nanoid(message) {
|
||||
return this._addCheck({ kind: "nanoid", ...errorUtil_1.errorUtil.errToObj(message) });
|
||||
}
|
||||
cuid(message) {
|
||||
return this._addCheck({ kind: "cuid", ...errorUtil_1.errorUtil.errToObj(message) });
|
||||
}
|
||||
@@ -47155,16 +47255,20 @@ class ZodString extends ZodType {
|
||||
ulid(message) {
|
||||
return this._addCheck({ kind: "ulid", ...errorUtil_1.errorUtil.errToObj(message) });
|
||||
}
|
||||
base64(message) {
|
||||
return this._addCheck({ kind: "base64", ...errorUtil_1.errorUtil.errToObj(message) });
|
||||
}
|
||||
ip(options) {
|
||||
return this._addCheck({ kind: "ip", ...errorUtil_1.errorUtil.errToObj(options) });
|
||||
}
|
||||
datetime(options) {
|
||||
var _a;
|
||||
var _a, _b;
|
||||
if (typeof options === "string") {
|
||||
return this._addCheck({
|
||||
kind: "datetime",
|
||||
precision: null,
|
||||
offset: false,
|
||||
local: false,
|
||||
message: options,
|
||||
});
|
||||
}
|
||||
@@ -47172,9 +47276,30 @@ class ZodString extends ZodType {
|
||||
kind: "datetime",
|
||||
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
||||
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
||||
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
||||
...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
||||
});
|
||||
}
|
||||
date(message) {
|
||||
return this._addCheck({ kind: "date", message });
|
||||
}
|
||||
time(options) {
|
||||
if (typeof options === "string") {
|
||||
return this._addCheck({
|
||||
kind: "time",
|
||||
precision: null,
|
||||
message: options,
|
||||
});
|
||||
}
|
||||
return this._addCheck({
|
||||
kind: "time",
|
||||
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
||||
...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
||||
});
|
||||
}
|
||||
duration(message) {
|
||||
return this._addCheck({ kind: "duration", ...errorUtil_1.errorUtil.errToObj(message) });
|
||||
}
|
||||
regex(regex, message) {
|
||||
return this._addCheck({
|
||||
kind: "regex",
|
||||
@@ -47253,6 +47378,15 @@ class ZodString extends ZodType {
|
||||
get isDatetime() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
||||
}
|
||||
get isDate() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "date");
|
||||
}
|
||||
get isTime() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "time");
|
||||
}
|
||||
get isDuration() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
||||
}
|
||||
get isEmail() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "email");
|
||||
}
|
||||
@@ -47265,6 +47399,9 @@ class ZodString extends ZodType {
|
||||
get isUUID() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
||||
}
|
||||
get isNANOID() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
||||
}
|
||||
get isCUID() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
||||
}
|
||||
@@ -47277,6 +47414,9 @@ class ZodString extends ZodType {
|
||||
get isIP() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
||||
}
|
||||
get isBase64() {
|
||||
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
||||
}
|
||||
get minLength() {
|
||||
let min = null;
|
||||
for (const ch of this._def.checks) {
|
||||
@@ -48278,9 +48418,10 @@ class ZodObject extends ZodType {
|
||||
const syncPairs = [];
|
||||
for (const pair of pairs) {
|
||||
const key = await pair.key;
|
||||
const value = await pair.value;
|
||||
syncPairs.push({
|
||||
key,
|
||||
value: await pair.value,
|
||||
value,
|
||||
alwaysSet: pair.alwaysSet,
|
||||
});
|
||||
}
|
||||
@@ -48656,7 +48797,7 @@ const getDiscriminator = (type) => {
|
||||
}
|
||||
else if (type instanceof ZodNativeEnum) {
|
||||
// eslint-disable-next-line ban/ban
|
||||
return Object.keys(type.enum);
|
||||
return util_1.util.objectValues(type.enum);
|
||||
}
|
||||
else if (type instanceof ZodDefault) {
|
||||
return getDiscriminator(type._def.innerType);
|
||||
@@ -48667,8 +48808,23 @@ const getDiscriminator = (type) => {
|
||||
else if (type instanceof ZodNull) {
|
||||
return [null];
|
||||
}
|
||||
else if (type instanceof ZodOptional) {
|
||||
return [undefined, ...getDiscriminator(type.unwrap())];
|
||||
}
|
||||
else if (type instanceof ZodNullable) {
|
||||
return [null, ...getDiscriminator(type.unwrap())];
|
||||
}
|
||||
else if (type instanceof ZodBranded) {
|
||||
return getDiscriminator(type.unwrap());
|
||||
}
|
||||
else if (type instanceof ZodReadonly) {
|
||||
return getDiscriminator(type.unwrap());
|
||||
}
|
||||
else if (type instanceof ZodCatch) {
|
||||
return getDiscriminator(type._def.innerType);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
};
|
||||
class ZodDiscriminatedUnion extends ZodType {
|
||||
@@ -48731,7 +48887,7 @@ class ZodDiscriminatedUnion extends ZodType {
|
||||
// try {
|
||||
for (const type of options) {
|
||||
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
||||
if (!discriminatorValues) {
|
||||
if (!discriminatorValues.length) {
|
||||
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
||||
}
|
||||
for (const value of discriminatorValues) {
|
||||
@@ -48947,6 +49103,7 @@ class ZodRecord extends ZodType {
|
||||
pairs.push({
|
||||
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
||||
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
||||
alwaysSet: key in ctx.data,
|
||||
});
|
||||
}
|
||||
if (ctx.common.async) {
|
||||
@@ -49312,6 +49469,10 @@ function createZodEnum(values, params) {
|
||||
});
|
||||
}
|
||||
class ZodEnum extends ZodType {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
_ZodEnum_cache.set(this, void 0);
|
||||
}
|
||||
_parse(input) {
|
||||
if (typeof input.data !== "string") {
|
||||
const ctx = this._getOrReturnCtx(input);
|
||||
@@ -49323,7 +49484,10 @@ class ZodEnum extends ZodType {
|
||||
});
|
||||
return parseUtil_1.INVALID;
|
||||
}
|
||||
if (this._def.values.indexOf(input.data) === -1) {
|
||||
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
||||
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
||||
}
|
||||
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
||||
const ctx = this._getOrReturnCtx(input);
|
||||
const expectedValues = this._def.values;
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
@@ -49359,16 +49523,27 @@ class ZodEnum extends ZodType {
|
||||
}
|
||||
return enumValues;
|
||||
}
|
||||
extract(values) {
|
||||
return ZodEnum.create(values);
|
||||
extract(values, newDef = this._def) {
|
||||
return ZodEnum.create(values, {
|
||||
...this._def,
|
||||
...newDef,
|
||||
});
|
||||
}
|
||||
exclude(values) {
|
||||
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
|
||||
exclude(values, newDef = this._def) {
|
||||
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
||||
...this._def,
|
||||
...newDef,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ZodEnum = ZodEnum;
|
||||
_ZodEnum_cache = new WeakMap();
|
||||
ZodEnum.create = createZodEnum;
|
||||
class ZodNativeEnum extends ZodType {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
_ZodNativeEnum_cache.set(this, void 0);
|
||||
}
|
||||
_parse(input) {
|
||||
const nativeEnumValues = util_1.util.getValidEnumValues(this._def.values);
|
||||
const ctx = this._getOrReturnCtx(input);
|
||||
@@ -49382,7 +49557,10 @@ class ZodNativeEnum extends ZodType {
|
||||
});
|
||||
return parseUtil_1.INVALID;
|
||||
}
|
||||
if (nativeEnumValues.indexOf(input.data) === -1) {
|
||||
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
||||
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util_1.util.getValidEnumValues(this._def.values)), "f");
|
||||
}
|
||||
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
||||
const expectedValues = util_1.util.objectValues(nativeEnumValues);
|
||||
(0, parseUtil_1.addIssueToContext)(ctx, {
|
||||
received: ctx.data,
|
||||
@@ -49398,6 +49576,7 @@ class ZodNativeEnum extends ZodType {
|
||||
}
|
||||
}
|
||||
exports.ZodNativeEnum = ZodNativeEnum;
|
||||
_ZodNativeEnum_cache = new WeakMap();
|
||||
ZodNativeEnum.create = (values, params) => {
|
||||
return new ZodNativeEnum({
|
||||
values: values,
|
||||
@@ -49468,33 +49647,43 @@ class ZodEffects extends ZodType {
|
||||
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
||||
if (effect.type === "preprocess") {
|
||||
const processed = effect.transform(ctx.data, checkCtx);
|
||||
if (ctx.common.issues.length) {
|
||||
return {
|
||||
status: "dirty",
|
||||
value: ctx.data,
|
||||
};
|
||||
}
|
||||
if (ctx.common.async) {
|
||||
return Promise.resolve(processed).then((processed) => {
|
||||
return this._def.schema._parseAsync({
|
||||
return Promise.resolve(processed).then(async (processed) => {
|
||||
if (status.value === "aborted")
|
||||
return parseUtil_1.INVALID;
|
||||
const result = await this._def.schema._parseAsync({
|
||||
data: processed,
|
||||
path: ctx.path,
|
||||
parent: ctx,
|
||||
});
|
||||
if (result.status === "aborted")
|
||||
return parseUtil_1.INVALID;
|
||||
if (result.status === "dirty")
|
||||
return (0, parseUtil_1.DIRTY)(result.value);
|
||||
if (status.value === "dirty")
|
||||
return (0, parseUtil_1.DIRTY)(result.value);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this._def.schema._parseSync({
|
||||
if (status.value === "aborted")
|
||||
return parseUtil_1.INVALID;
|
||||
const result = this._def.schema._parseSync({
|
||||
data: processed,
|
||||
path: ctx.path,
|
||||
parent: ctx,
|
||||
});
|
||||
if (result.status === "aborted")
|
||||
return parseUtil_1.INVALID;
|
||||
if (result.status === "dirty")
|
||||
return (0, parseUtil_1.DIRTY)(result.value);
|
||||
if (status.value === "dirty")
|
||||
return (0, parseUtil_1.DIRTY)(result.value);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (effect.type === "refinement") {
|
||||
const executeRefinement = (acc
|
||||
// effect: RefinementEffect<any>
|
||||
) => {
|
||||
const executeRefinement = (acc) => {
|
||||
const result = effect.refinement(acc, checkCtx);
|
||||
if (ctx.common.async) {
|
||||
return Promise.resolve(result);
|
||||
@@ -49806,10 +49995,18 @@ exports.ZodPipeline = ZodPipeline;
|
||||
class ZodReadonly extends ZodType {
|
||||
_parse(input) {
|
||||
const result = this._def.innerType._parse(input);
|
||||
if ((0, parseUtil_1.isValid)(result)) {
|
||||
result.value = Object.freeze(result.value);
|
||||
}
|
||||
return result;
|
||||
const freeze = (data) => {
|
||||
if ((0, parseUtil_1.isValid)(data)) {
|
||||
data.value = Object.freeze(data.value);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
return (0, parseUtil_1.isAsync)(result)
|
||||
? result.then((data) => freeze(data))
|
||||
: freeze(result);
|
||||
}
|
||||
unwrap() {
|
||||
return this._def.innerType;
|
||||
}
|
||||
}
|
||||
exports.ZodReadonly = ZodReadonly;
|
||||
@@ -49820,7 +50017,7 @@ ZodReadonly.create = (type, params) => {
|
||||
...processCreateParams(params),
|
||||
});
|
||||
};
|
||||
const custom = (check, params = {},
|
||||
function custom(check, params = {},
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
@@ -49831,7 +50028,7 @@ const custom = (check, params = {},
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
fatal) => {
|
||||
fatal) {
|
||||
if (check)
|
||||
return ZodAny.create().superRefine((data, ctx) => {
|
||||
var _a, _b;
|
||||
@@ -49847,7 +50044,7 @@ fatal) => {
|
||||
}
|
||||
});
|
||||
return ZodAny.create();
|
||||
};
|
||||
}
|
||||
exports.custom = custom;
|
||||
exports.late = {
|
||||
object: ZodObject.lazycreate,
|
||||
@@ -49899,7 +50096,7 @@ const instanceOfType = (
|
||||
// const instanceOfType = <T extends new (...args: any[]) => any>(
|
||||
cls, params = {
|
||||
message: `Input not instance of ${cls.name}`,
|
||||
}) => (0, exports.custom)((data) => data instanceof cls, params);
|
||||
}) => custom((data) => data instanceof cls, params);
|
||||
exports["instanceof"] = instanceOfType;
|
||||
const stringType = ZodString.create;
|
||||
exports.string = stringType;
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
8
package-lock.json
generated
8
package-lock.json
generated
@@ -22,7 +22,7 @@
|
||||
"spdx-satisfies": "^5.0.1",
|
||||
"ts-jest": "^29.1.2",
|
||||
"yaml": "^2.3.4",
|
||||
"zod": "^3.22.3"
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
@@ -8209,9 +8209,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.22.4",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
|
||||
"integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
|
||||
"version": "3.23.8",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
|
||||
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"spdx-satisfies": "^5.0.1",
|
||||
"ts-jest": "^29.1.2",
|
||||
"yaml": "^2.3.4",
|
||||
"zod": "^3.22.3"
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
|
||||
Reference in New Issue
Block a user