Socket
Socket
Sign inDemoInstall

zod

Package Overview
Dependencies
0
Maintainers
2
Versions
359
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.11.6 to 3.22.3

index.d.ts

1

lib/benchmarks/index.d.ts
export {};
//# sourceMappingURL=index.d.ts.map
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var e_1, _a;
Object.defineProperty(exports, "__esModule", { value: true });
var object_1 = __importDefault(require("./object"));
var string_1 = __importDefault(require("./string"));
var union_1 = __importDefault(require("./union"));
try {
for (var _b = __values(__spreadArray(__spreadArray(__spreadArray([], __read(string_1.default.suites), false), __read(object_1.default.suites), false), __read(union_1.default.suites), false)), _c = _b.next(); !_c.done; _c = _b.next()) {
var suite = _c.value;
suite.run();
}
const discriminatedUnion_1 = __importDefault(require("./discriminatedUnion"));
const object_1 = __importDefault(require("./object"));
const primitives_1 = __importDefault(require("./primitives"));
const realworld_1 = __importDefault(require("./realworld"));
const string_1 = __importDefault(require("./string"));
const union_1 = __importDefault(require("./union"));
const argv = process.argv.slice(2);
let suites = [];
if (!argv.length) {
suites = [
...realworld_1.default.suites,
...primitives_1.default.suites,
...string_1.default.suites,
...object_1.default.suites,
...union_1.default.suites,
...discriminatedUnion_1.default.suites,
];
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
else {
if (argv.includes("--realworld")) {
suites.push(...realworld_1.default.suites);
}
finally { if (e_1) throw e_1.error; }
if (argv.includes("--primitives")) {
suites.push(...primitives_1.default.suites);
}
if (argv.includes("--string")) {
suites.push(...string_1.default.suites);
}
if (argv.includes("--object")) {
suites.push(...object_1.default.suites);
}
if (argv.includes("--union")) {
suites.push(...union_1.default.suites);
}
if (argv.includes("--discriminatedUnion")) {
suites.push(...discriminatedUnion_1.default.suites);
}
}
//# sourceMappingURL=index.js.map
for (const suite of suites) {
suite.run();
}

@@ -6,2 +6,1 @@ import Benchmark from "benchmark";

export default _default;
//# sourceMappingURL=object.d.ts.map

@@ -6,12 +6,12 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var benchmark_1 = __importDefault(require("benchmark"));
var index_1 = require("../index");
var emptySuite = new benchmark_1.default.Suite("z.object: empty");
var shortSuite = new benchmark_1.default.Suite("z.object: short");
var longSuite = new benchmark_1.default.Suite("z.object: long");
var empty = index_1.z.object({});
var short = index_1.z.object({
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const emptySuite = new benchmark_1.default.Suite("z.object: empty");
const shortSuite = new benchmark_1.default.Suite("z.object: short");
const longSuite = new benchmark_1.default.Suite("z.object: long");
const empty = index_1.z.object({});
const short = index_1.z.object({
string: index_1.z.string(),
});
var long = index_1.z.object({
const long = index_1.z.object({
string: index_1.z.string(),

@@ -22,9 +22,9 @@ number: index_1.z.number(),

emptySuite
.add("valid", function () {
.add("valid", () => {
empty.parse({});
})
.add("valid: extra keys", function () {
.add("valid: extra keys", () => {
empty.parse({ string: "string" });
})
.add("invalid: null", function () {
.add("invalid: null", () => {
try {

@@ -35,13 +35,13 @@ empty.parse(null);

})
.on("cycle", function (e) {
console.log(emptySuite.name + ": " + e.target);
.on("cycle", (e) => {
console.log(`${emptySuite.name}: ${e.target}`);
});
shortSuite
.add("valid", function () {
.add("valid", () => {
short.parse({ string: "string" });
})
.add("valid: extra keys", function () {
.add("valid: extra keys", () => {
short.parse({ string: "string", number: 42 });
})
.add("invalid: null", function () {
.add("invalid: null", () => {
try {

@@ -52,13 +52,13 @@ short.parse(null);

})
.on("cycle", function (e) {
console.log(shortSuite.name + ": " + e.target);
.on("cycle", (e) => {
console.log(`${shortSuite.name}: ${e.target}`);
});
longSuite
.add("valid", function () {
.add("valid", () => {
long.parse({ string: "string", number: 42, boolean: true });
})
.add("valid: extra keys", function () {
.add("valid: extra keys", () => {
long.parse({ string: "string", number: 42, boolean: true, list: [] });
})
.add("invalid: null", function () {
.add("invalid: null", () => {
try {

@@ -69,4 +69,4 @@ long.parse(null);

})
.on("cycle", function (e) {
console.log(longSuite.name + ": " + e.target);
.on("cycle", (e) => {
console.log(`${longSuite.name}: ${e.target}`);
});

@@ -76,2 +76,1 @@ exports.default = {

};
//# sourceMappingURL=object.js.map

@@ -6,2 +6,1 @@ import Benchmark from "benchmark";

export default _default;
//# sourceMappingURL=string.d.ts.map

@@ -6,10 +6,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var benchmark_1 = __importDefault(require("benchmark"));
var index_1 = require("../index");
var SUITE_NAME = "z.string";
var suite = new benchmark_1.default.Suite(SUITE_NAME);
var empty = "";
var short = "short";
var long = "long".repeat(256);
var manual = function (str) {
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const SUITE_NAME = "z.string";
const suite = new benchmark_1.default.Suite(SUITE_NAME);
const empty = "";
const short = "short";
const long = "long".repeat(256);
const manual = (str) => {
if (typeof str !== "string") {

@@ -20,14 +20,25 @@ throw new Error("Not a string");

};
var stringSchema = index_1.z.string();
const stringSchema = index_1.z.string();
const optionalStringSchema = index_1.z.string().optional();
const optionalNullableStringSchema = index_1.z.string().optional().nullable();
suite
.add("empty string", function () {
.add("empty string", () => {
stringSchema.parse(empty);
})
.add("short string", function () {
.add("short string", () => {
stringSchema.parse(short);
})
.add("long string", function () {
.add("long string", () => {
stringSchema.parse(long);
})
.add("invalid: null", function () {
.add("optional string", () => {
optionalStringSchema.parse(long);
})
.add("nullable string", () => {
optionalNullableStringSchema.parse(long);
})
.add("nullable (null) string", () => {
optionalNullableStringSchema.parse(null);
})
.add("invalid: null", () => {
try {

@@ -38,7 +49,7 @@ stringSchema.parse(null);

})
.add("manual parser: long", function () {
.add("manual parser: long", () => {
manual(long);
})
.on("cycle", function (e) {
console.log(SUITE_NAME + ": " + e.target);
.on("cycle", (e) => {
console.log(`${SUITE_NAME}: ${e.target}`);
});

@@ -48,2 +59,1 @@ exports.default = {

};
//# sourceMappingURL=string.js.map

@@ -6,2 +6,1 @@ import Benchmark from "benchmark";

export default _default;
//# sourceMappingURL=union.d.ts.map

@@ -6,37 +6,37 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var benchmark_1 = __importDefault(require("benchmark"));
var index_1 = require("../index");
var doubleSuite = new benchmark_1.default.Suite("z.union: double");
var manySuite = new benchmark_1.default.Suite("z.union: many");
var aSchema = index_1.z.object({
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const doubleSuite = new benchmark_1.default.Suite("z.union: double");
const manySuite = new benchmark_1.default.Suite("z.union: many");
const aSchema = index_1.z.object({
type: index_1.z.literal("a"),
});
var objA = {
const objA = {
type: "a",
};
var bSchema = index_1.z.object({
const bSchema = index_1.z.object({
type: index_1.z.literal("b"),
});
var objB = {
const objB = {
type: "b",
};
var cSchema = index_1.z.object({
const cSchema = index_1.z.object({
type: index_1.z.literal("c"),
});
var objC = {
const objC = {
type: "c",
};
var dSchema = index_1.z.object({
const dSchema = index_1.z.object({
type: index_1.z.literal("d"),
});
var double = index_1.z.union([aSchema, bSchema]);
var many = index_1.z.union([aSchema, bSchema, cSchema, dSchema]);
const double = index_1.z.union([aSchema, bSchema]);
const many = index_1.z.union([aSchema, bSchema, cSchema, dSchema]);
doubleSuite
.add("valid: a", function () {
.add("valid: a", () => {
double.parse(objA);
})
.add("valid: b", function () {
.add("valid: b", () => {
double.parse(objB);
})
.add("invalid: null", function () {
.add("invalid: null", () => {
try {

@@ -47,3 +47,3 @@ double.parse(null);

})
.add("invalid: wrong shape", function () {
.add("invalid: wrong shape", () => {
try {

@@ -54,13 +54,13 @@ double.parse(objC);

})
.on("cycle", function (e) {
console.log(doubleSuite.name + ": " + e.target);
.on("cycle", (e) => {
console.log(`${doubleSuite.name}: ${e.target}`);
});
manySuite
.add("valid: a", function () {
.add("valid: a", () => {
many.parse(objA);
})
.add("valid: c", function () {
.add("valid: c", () => {
many.parse(objC);
})
.add("invalid: null", function () {
.add("invalid: null", () => {
try {

@@ -71,3 +71,3 @@ many.parse(null);

})
.add("invalid: wrong shape", function () {
.add("invalid: wrong shape", () => {
try {

@@ -78,4 +78,4 @@ many.parse({ type: "unknown" });

})
.on("cycle", function (e) {
console.log(manySuite.name + ": " + e.target);
.on("cycle", (e) => {
console.log(`${manySuite.name}: ${e.target}`);
});

@@ -85,2 +85,1 @@ exports.default = {

};
//# sourceMappingURL=union.js.map

@@ -0,4 +1,6 @@

export * from "./errors";
export * from "./helpers/parseUtil";
export * from "./helpers/typeAliases";
export * from "./helpers/util";
export * from "./types";
export * from "./ZodError";
//# sourceMappingURL=external.d.ts.map

@@ -13,5 +13,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./errors"), exports);
__exportStar(require("./helpers/parseUtil"), exports);
__exportStar(require("./helpers/typeAliases"), exports);
__exportStar(require("./helpers/util"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./ZodError"), exports);
//# sourceMappingURL=external.js.map

@@ -10,2 +10,1 @@ export declare namespace errorUtil {

}
//# sourceMappingURL=errorUtil.d.ts.map

@@ -6,9 +6,4 @@ "use strict";

(function (errorUtil) {
errorUtil.errToObj = function (message) {
return typeof message === "string" ? { message: message } : message || {};
};
errorUtil.toString = function (message) {
return typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
};
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
})(errorUtil = exports.errorUtil || (exports.errorUtil = {}));
//# sourceMappingURL=errorUtil.js.map

@@ -1,26 +0,3 @@

import { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
export declare const ZodParsedType: {
function: "function";
number: "number";
string: "string";
nan: "nan";
integer: "integer";
float: "float";
boolean: "boolean";
date: "date";
bigint: "bigint";
symbol: "symbol";
undefined: "undefined";
null: "null";
array: "array";
object: "object";
unknown: "unknown";
promise: "promise";
void: "void";
never: "never";
map: "map";
set: "set";
};
export declare type ZodParsedType = keyof typeof ZodParsedType;
export declare const getParsedType: (data: any, cache?: Map<any, "function" | "number" | "string" | "nan" | "integer" | "float" | "boolean" | "date" | "bigint" | "symbol" | "undefined" | "null" | "array" | "object" | "unknown" | "promise" | "void" | "never" | "map" | "set"> | undefined) => ZodParsedType;
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
import type { ZodParsedType } from "./util";
export declare const makeIssue: (params: {

@@ -41,9 +18,10 @@ data: any;

export interface ParseContext {
readonly common: {
readonly issues: ZodIssue[];
readonly contextualErrorMap?: ZodErrorMap;
readonly async: boolean;
};
readonly path: ParsePath;
readonly issues: ZodIssue[];
readonly schemaErrorMap?: ZodErrorMap;
readonly contextualErrorMap?: ZodErrorMap;
readonly async: boolean;
readonly parent: ParseContext | null;
readonly typeCache: Map<any, ZodParsedType>;
readonly data: any;

@@ -102,2 +80,1 @@ readonly parsedType: ZodParsedType;

export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;
//# sourceMappingURL=parseUtil.d.ts.map
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
const errors_1 = require("../errors");
const en_1 = __importDefault(require("../locales/en"));
const makeIssue = (params) => {
const { data, path, errorMaps, issueData } = params;
const fullPath = [...path, ...(issueData.path || [])];
const fullIssue = {
...issueData,
path: fullPath,
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = exports.getParsedType = exports.ZodParsedType = void 0;
var ZodError_1 = require("../ZodError");
var util_1 = require("./util");
exports.ZodParsedType = util_1.util.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set",
]);
function cacheAndReturn(data, parsedType, cache) {
if (cache)
cache.set(data, parsedType);
return parsedType;
}
var getParsedType = function (data, cache) {
if (cache && cache.has(data))
return cache.get(data);
var t = typeof data;
switch (t) {
case "undefined":
return cacheAndReturn(data, exports.ZodParsedType.undefined, cache);
case "string":
return cacheAndReturn(data, exports.ZodParsedType.string, cache);
case "number":
return cacheAndReturn(data, isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number, cache);
case "boolean":
return cacheAndReturn(data, exports.ZodParsedType.boolean, cache);
case "function":
return cacheAndReturn(data, exports.ZodParsedType.function, cache);
case "bigint":
return cacheAndReturn(data, exports.ZodParsedType.bigint, cache);
case "object":
if (Array.isArray(data)) {
return cacheAndReturn(data, exports.ZodParsedType.array, cache);
}
if (data === null) {
return cacheAndReturn(data, exports.ZodParsedType.null, cache);
}
if (data.then &&
typeof data.then === "function" &&
data.catch &&
typeof data.catch === "function") {
return cacheAndReturn(data, exports.ZodParsedType.promise, cache);
}
if (data instanceof Map) {
return cacheAndReturn(data, exports.ZodParsedType.map, cache);
}
if (data instanceof Set) {
return cacheAndReturn(data, exports.ZodParsedType.set, cache);
}
if (data instanceof Date) {
return cacheAndReturn(data, exports.ZodParsedType.date, cache);
}
return cacheAndReturn(data, exports.ZodParsedType.object, cache);
default:
return cacheAndReturn(data, exports.ZodParsedType.unknown, cache);
}
};
exports.getParsedType = getParsedType;
var makeIssue = function (params) {
var e_1, _a;
var data = params.data, path = params.path, errorMaps = params.errorMaps, issueData = params.issueData;
var fullPath = __spreadArray(__spreadArray([], __read(path), false), __read((issueData.path || [])), false);
var fullIssue = __assign(__assign({}, issueData), { path: fullPath });
var errorMessage = "";
var maps = errorMaps
.filter(function (m) { return !!m; })
let errorMessage = "";
const maps = errorMaps
.filter((m) => !!m)
.slice()
.reverse();
try {
for (var maps_1 = __values(maps), maps_1_1 = maps_1.next(); !maps_1_1.done; maps_1_1 = maps_1.next()) {
var map = maps_1_1.value;
errorMessage = map(fullIssue, { data: data, defaultError: errorMessage }).message;
}
for (const map of maps) {
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (maps_1_1 && !maps_1_1.done && (_a = maps_1.return)) _a.call(maps_1);
}
finally { if (e_1) throw e_1.error; }
}
return __assign(__assign({}, issueData), { path: fullPath, message: issueData.message || errorMessage });
return {
...issueData,
path: fullPath,
message: issueData.message || errorMessage,
};
};

@@ -189,3 +33,3 @@ exports.makeIssue = makeIssue;

function addIssueToContext(ctx, issueData) {
var issue = (0, exports.makeIssue)({
const issue = (0, exports.makeIssue)({
issueData: issueData,

@@ -195,121 +39,64 @@ data: ctx.data,

errorMaps: [
ctx.contextualErrorMap,
ctx.common.contextualErrorMap,
ctx.schemaErrorMap,
ZodError_1.overrideErrorMap,
ZodError_1.defaultErrorMap, // then global default map
].filter(function (x) { return !!x; }),
(0, errors_1.getErrorMap)(),
en_1.default,
].filter((x) => !!x),
});
ctx.issues.push(issue);
ctx.common.issues.push(issue);
}
exports.addIssueToContext = addIssueToContext;
var ParseStatus = /** @class */ (function () {
function ParseStatus() {
class ParseStatus {
constructor() {
this.value = "valid";
}
ParseStatus.prototype.dirty = function () {
dirty() {
if (this.value === "valid")
this.value = "dirty";
};
ParseStatus.prototype.abort = function () {
}
abort() {
if (this.value !== "aborted")
this.value = "aborted";
};
ParseStatus.mergeArray = function (status, results) {
var e_2, _a;
var arrayValue = [];
try {
for (var results_1 = __values(results), results_1_1 = results_1.next(); !results_1_1.done; results_1_1 = results_1.next()) {
var s = results_1_1.value;
if (s.status === "aborted")
return exports.INVALID;
if (s.status === "dirty")
status.dirty();
arrayValue.push(s.value);
}
}
static mergeArray(status, results) {
const arrayValue = [];
for (const s of results) {
if (s.status === "aborted")
return exports.INVALID;
if (s.status === "dirty")
status.dirty();
arrayValue.push(s.value);
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (results_1_1 && !results_1_1.done && (_a = results_1.return)) _a.call(results_1);
}
finally { if (e_2) throw e_2.error; }
}
return { status: status.value, value: arrayValue };
};
ParseStatus.mergeObjectAsync = function (status, pairs) {
return __awaiter(this, void 0, void 0, function () {
var syncPairs, pairs_1, pairs_1_1, pair, _a, _b, e_3_1;
var e_3, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
syncPairs = [];
_e.label = 1;
case 1:
_e.trys.push([1, 7, 8, 9]);
pairs_1 = __values(pairs), pairs_1_1 = pairs_1.next();
_e.label = 2;
case 2:
if (!!pairs_1_1.done) return [3 /*break*/, 6];
pair = pairs_1_1.value;
_b = (_a = syncPairs).push;
_d = {};
return [4 /*yield*/, pair.key];
case 3:
_d.key = _e.sent();
return [4 /*yield*/, pair.value];
case 4:
_b.apply(_a, [(_d.value = _e.sent(),
_d)]);
_e.label = 5;
case 5:
pairs_1_1 = pairs_1.next();
return [3 /*break*/, 2];
case 6: return [3 /*break*/, 9];
case 7:
e_3_1 = _e.sent();
e_3 = { error: e_3_1 };
return [3 /*break*/, 9];
case 8:
try {
if (pairs_1_1 && !pairs_1_1.done && (_c = pairs_1.return)) _c.call(pairs_1);
}
finally { if (e_3) throw e_3.error; }
return [7 /*endfinally*/];
case 9: return [2 /*return*/, ParseStatus.mergeObjectSync(status, syncPairs)];
}
}
static async mergeObjectAsync(status, pairs) {
const syncPairs = [];
for (const pair of pairs) {
syncPairs.push({
key: await pair.key,
value: await pair.value,
});
});
};
ParseStatus.mergeObjectSync = function (status, pairs) {
var e_4, _a;
var finalObject = {};
try {
for (var pairs_2 = __values(pairs), pairs_2_1 = pairs_2.next(); !pairs_2_1.done; pairs_2_1 = pairs_2.next()) {
var pair = pairs_2_1.value;
var key = pair.key, value = pair.value;
if (key.status === "aborted")
return exports.INVALID;
if (value.status === "aborted")
return exports.INVALID;
if (key.status === "dirty")
status.dirty();
if (value.status === "dirty")
status.dirty();
if (typeof value.value !== "undefined" || pair.alwaysSet) {
finalObject[key.value] = value.value;
}
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (pairs_2_1 && !pairs_2_1.done && (_a = pairs_2.return)) _a.call(pairs_2);
return ParseStatus.mergeObjectSync(status, syncPairs);
}
static mergeObjectSync(status, pairs) {
const finalObject = {};
for (const pair of pairs) {
const { key, value } = pair;
if (key.status === "aborted")
return exports.INVALID;
if (value.status === "aborted")
return exports.INVALID;
if (key.status === "dirty")
status.dirty();
if (value.status === "dirty")
status.dirty();
if (key.value !== "__proto__" &&
(typeof value.value !== "undefined" || pair.alwaysSet)) {
finalObject[key.value] = value.value;
}
finally { if (e_4) throw e_4.error; }
}
return { status: status.value, value: finalObject };
};
return ParseStatus;
}());
}
}
exports.ParseStatus = ParseStatus;

@@ -319,20 +106,13 @@ exports.INVALID = Object.freeze({

});
var DIRTY = function (value) { return ({ status: "dirty", value: value }); };
const DIRTY = (value) => ({ status: "dirty", value });
exports.DIRTY = DIRTY;
var OK = function (value) { return ({ status: "valid", value: value }); };
const OK = (value) => ({ status: "valid", value });
exports.OK = OK;
var isAborted = function (x) {
return x.status === "aborted";
};
const isAborted = (x) => x.status === "aborted";
exports.isAborted = isAborted;
var isDirty = function (x) {
return x.status === "dirty";
};
const isDirty = (x) => x.status === "dirty";
exports.isDirty = isDirty;
var isValid = function (x) {
return x.status === "valid";
};
const isValid = (x) => x.status === "valid";
exports.isValid = isValid;
var isAsync = function (x) { return x instanceof Promise; };
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
exports.isAsync = isAsync;
//# sourceMappingURL=parseUtil.js.map

@@ -1,9 +0,8 @@

import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodTuple, ZodTupleItems, ZodTypeAny } from "../index";
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../index";
export declare namespace partialUtil {
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<infer Shape, infer Params, infer Catchall> ? ZodObject<{
[k in keyof Shape]: ZodOptional<DeepPartial<Shape[k]>>;
}, Params, Catchall> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
}, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
}
//# sourceMappingURL=partialUtil.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=partialUtil.js.map
export declare namespace util {
type AssertEqual<T, Expected> = [T] extends [Expected] ? [Expected] extends [T] ? true : false : false;
function assertNever(_x: never): never;
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
const getValidEnumValues: (obj: any) => any[];
const objectValues: (obj: any) => any[];
const objectKeys: ObjectConstructor["keys"];
const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
type identity<T> = T;
type flatten<T extends object> = identity<{
type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
export type isAny<T> = 0 extends 1 & T ? true : false;
export const assertEqual: <A, B>(val: AssertEqual<A, B>) => AssertEqual<A, B>;
export function assertIs<T>(_arg: T): void;
export function assertNever(_x: never): never;
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
export const getValidEnumValues: (obj: any) => any[];
export const objectValues: (obj: any) => any[];
export const objectKeys: ObjectConstructor["keys"];
export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
export type identity<T> = objectUtil.identity<T>;
export type flatten<T> = objectUtil.flatten<T>;
export type noUndefined<T> = T extends undefined ? never : T;
export const isInteger: NumberConstructor["isInteger"];
export function joinValues<T extends any[]>(array: T, separator?: string): string;
export const jsonStringifyReplacer: (_: string, value: any) => any;
export {};
}
export declare namespace objectUtil {
export type MergeShapes<U, V> = {
[k in Exclude<keyof U, keyof V>]: U[k];
} & V;
type requiredKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? never : k;
}[keyof T];
export type addQuestionMarks<T extends object, R extends keyof T = requiredKeys<T>> = Pick<Required<T>, R> & Partial<T>;
export type identity<T> = T;
export type flatten<T> = identity<{
[k in keyof T]: T[k];
}>;
type noUndefined<T> = T extends undefined ? never : T;
const isInteger: NumberConstructor["isInteger"];
export type noNeverKeys<T> = {
[k in keyof T]: [T[k]] extends [never] ? never : k;
}[keyof T];
export type noNever<T> = identity<{
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
}>;
export const mergeShapes: <U, T>(first: U, second: T) => T & U;
export type extendShape<A, B> = flatten<Omit<A, keyof B> & B>;
export {};
}
//# sourceMappingURL=util.d.ts.map
export declare const ZodParsedType: {
function: "function";
number: "number";
string: "string";
nan: "nan";
integer: "integer";
float: "float";
boolean: "boolean";
date: "date";
bigint: "bigint";
symbol: "symbol";
undefined: "undefined";
null: "null";
array: "array";
object: "object";
unknown: "unknown";
promise: "promise";
void: "void";
never: "never";
map: "map";
set: "set";
};
export declare type ZodParsedType = keyof typeof ZodParsedType;
export declare const getParsedType: (data: any) => ZodParsedType;
"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
var util;
(function (util) {
util.assertEqual = (val) => val;
function assertIs(_arg) { }
util.assertIs = assertIs;
function assertNever(_x) {

@@ -21,40 +13,18 @@ throw new Error();

util.assertNever = assertNever;
util.arrayToEnum = function (items) {
var e_1, _a;
var obj = {};
try {
for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
var item = items_1_1.value;
obj[item] = item;
}
util.arrayToEnum = (items) => {
const obj = {};
for (const item of items) {
obj[item] = item;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
}
finally { if (e_1) throw e_1.error; }
}
return obj;
};
util.getValidEnumValues = function (obj) {
var e_2, _a;
var validKeys = util.objectKeys(obj).filter(function (k) { return typeof obj[obj[k]] !== "number"; });
var filtered = {};
try {
for (var validKeys_1 = __values(validKeys), validKeys_1_1 = validKeys_1.next(); !validKeys_1_1.done; validKeys_1_1 = validKeys_1.next()) {
var k = validKeys_1_1.value;
filtered[k] = obj[k];
}
util.getValidEnumValues = (obj) => {
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
const filtered = {};
for (const k of validKeys) {
filtered[k] = obj[k];
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (validKeys_1_1 && !validKeys_1_1.done && (_a = validKeys_1.return)) _a.call(validKeys_1);
}
finally { if (e_2) throw e_2.error; }
}
return util.objectValues(filtered);
};
util.objectValues = function (obj) {
util.objectValues = (obj) => {
return util.objectKeys(obj).map(function (e) {

@@ -64,7 +34,7 @@ return obj[e];

};
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
? function (obj) { return Object.keys(obj); } // eslint-disable-line ban/ban
: function (object) {
var keys = [];
for (var key in object) {
util.objectKeys = typeof Object.keys === "function"
? (obj) => Object.keys(obj)
: (object) => {
const keys = [];
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {

@@ -76,26 +46,100 @@ keys.push(key);

};
util.find = function (arr, checker) {
var e_3, _a;
try {
for (var arr_1 = __values(arr), arr_1_1 = arr_1.next(); !arr_1_1.done; arr_1_1 = arr_1.next()) {
var item = arr_1_1.value;
if (checker(item))
return item;
}
util.find = (arr, checker) => {
for (const item of arr) {
if (checker(item))
return item;
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1);
}
finally { if (e_3) throw e_3.error; }
}
return undefined;
};
util.isInteger = typeof Number.isInteger === "function"
? function (val) { return Number.isInteger(val); } // eslint-disable-line ban/ban
: function (val) {
return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
? (val) => Number.isInteger(val)
: (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
function joinValues(array, separator = " | ") {
return array
.map((val) => (typeof val === "string" ? `'${val}'` : val))
.join(separator);
}
util.joinValues = joinValues;
util.jsonStringifyReplacer = (_, value) => {
if (typeof value === "bigint") {
return value.toString();
}
return value;
};
})(util = exports.util || (exports.util = {}));
var objectUtil;
(function (objectUtil) {
objectUtil.mergeShapes = (first, second) => {
return {
...first,
...second,
};
})(util = exports.util || (exports.util = {}));
//# sourceMappingURL=util.js.map
};
})(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
exports.ZodParsedType = util.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set",
]);
const getParsedType = (data) => {
const t = typeof data;
switch (t) {
case "undefined":
return exports.ZodParsedType.undefined;
case "string":
return exports.ZodParsedType.string;
case "number":
return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
case "boolean":
return exports.ZodParsedType.boolean;
case "function":
return exports.ZodParsedType.function;
case "bigint":
return exports.ZodParsedType.bigint;
case "symbol":
return exports.ZodParsedType.symbol;
case "object":
if (Array.isArray(data)) {
return exports.ZodParsedType.array;
}
if (data === null) {
return exports.ZodParsedType.null;
}
if (data.then &&
typeof data.then === "function" &&
data.catch &&
typeof data.catch === "function") {
return exports.ZodParsedType.promise;
}
if (typeof Map !== "undefined" && data instanceof Map) {
return exports.ZodParsedType.map;
}
if (typeof Set !== "undefined" && data instanceof Set) {
return exports.ZodParsedType.set;
}
if (typeof Date !== "undefined" && data instanceof Date) {
return exports.ZodParsedType.date;
}
return exports.ZodParsedType.object;
default:
return exports.ZodParsedType.unknown;
}
};
exports.getParsedType = getParsedType;

@@ -1,4 +0,4 @@

import * as mod from "./external";
import * as z from "./external";
export * from "./external";
export { mod as z };
//# sourceMappingURL=index.d.ts.map
export { z };
export default z;

@@ -26,5 +26,5 @@ "use strict";

exports.z = void 0;
var mod = __importStar(require("./external"));
exports.z = mod;
const z = __importStar(require("./external"));
exports.z = z;
__exportStar(require("./external"), exports);
//# sourceMappingURL=index.js.map
exports.default = z;

@@ -0,5 +1,7 @@

import { enumUtil } from "./helpers/enumUtil";
import { errorUtil } from "./helpers/errorUtil";
import { AsyncParseReturnType, ParseContext, ParseInput, ParseParams, ParseReturnType, ParseStatus, SyncParseReturnType } from "./helpers/parseUtil";
import { partialUtil } from "./helpers/partialUtil";
import { util } from "./helpers/util";
import { Primitive } from "./helpers/typeAliases";
import { objectUtil, util } from "./helpers/util";
import { IssueData, StringValidation, ZodCustomIssue, ZodError, ZodErrorMap } from "./ZodError";

@@ -23,3 +25,3 @@ export declare type RefinementCtx = {

}
declare type RawCreateParams = {
export declare type RawCreateParams = {
errorMap?: ZodErrorMap;

@@ -30,2 +32,6 @@ invalid_type_error?: string;

} | undefined;
export declare type ProcessedCreateParams = {
errorMap?: ZodErrorMap;
description?: string;
};
export declare type SafeParseSuccess<Output> = {

@@ -40,3 +46,3 @@ success: true;

export declare type SafeParseReturnType<Input, Output> = SafeParseSuccess<Output> | SafeParseError<Input>;
export declare abstract class ZodType<Output, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
readonly _type: Output;

@@ -48,2 +54,4 @@ readonly _output: Output;

abstract _parse(input: ParseInput): ParseReturnType<Output>;
_getType(input: ParseInput): string;
_getOrReturnCtx(input: ParseInput, ctx?: ParseContext | undefined): ParseContext;
_processInputParams(input: ParseInput): {

@@ -59,18 +67,15 @@ status: ParseStatus;

safeParseAsync(data: unknown, params?: Partial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>;
/** Alias of safeParseAsync */
spa: (data: unknown, params?: Partial<ParseParams> | undefined) => Promise<SafeParseReturnType<Input, Output>>;
/** The .is method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3. */
is: never;
/** The .check method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3. */
check: never;
refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, RefinedOutput>;
refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, Input>;
refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>;
refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, RefinedOutput>;
refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, Input>;
refinement(check: (arg: Output) => boolean, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, Output, Input>;
_refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>;
superRefine: (refinement: RefinementEffect<Output>["refinement"]) => ZodEffects<this, Output, Input>;
superRefine<RefinedOutput extends Output>(refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput): ZodEffects<this, RefinedOutput, Input>;
superRefine(refinement: (arg: Output, ctx: RefinementCtx) => void): ZodEffects<this, Output, Input>;
superRefine(refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>): ZodEffects<this, Output, Input>;
constructor(def: Def);
optional(): ZodOptional<this>;
nullable(): ZodNullable<this>;
nullish(): ZodNullable<ZodOptional<this>>;
nullish(): ZodOptional<ZodNullable<this>>;
array(): ZodArray<this>;

@@ -80,10 +85,19 @@ promise(): ZodPromise<this>;

and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>;
transform<NewOut>(transform: (arg: Output) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>;
transform<NewOut>(transform: (arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>;
default(def: util.noUndefined<Input>): ZodDefault<this>;
default(def: () => util.noUndefined<Input>): ZodDefault<this>;
brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
catch(def: Output): ZodCatch<this>;
catch(def: (ctx: {
error: ZodError;
input: Input;
}) => Output): ZodCatch<this>;
describe(description: string): this;
pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
readonly(): ZodReadonly<this>;
isOptional(): boolean;
isNullable(): boolean;
}
declare type ZodStringCheck = {
export declare type IpVersion = "v4" | "v6";
export declare type ZodStringCheck = {
kind: "min";

@@ -97,2 +111,6 @@ value: number;

} | {
kind: "length";
value: number;
message?: string;
} | {
kind: "email";

@@ -104,2 +122,5 @@ message?: string;

} | {
kind: "emoji";
message?: string;
} | {
kind: "uuid";

@@ -111,5 +132,42 @@ message?: string;

} | {
kind: "includes";
value: string;
position?: number;
message?: string;
} | {
kind: "cuid2";
message?: string;
} | {
kind: "ulid";
message?: string;
} | {
kind: "startsWith";
value: string;
message?: string;
} | {
kind: "endsWith";
value: string;
message?: string;
} | {
kind: "regex";
regex: RegExp;
message?: string;
} | {
kind: "trim";
message?: string;
} | {
kind: "toLowerCase";
message?: string;
} | {
kind: "toUpperCase";
message?: string;
} | {
kind: "datetime";
offset: boolean;
precision: number | null;
message?: string;
} | {
kind: "ip";
version?: IpVersion;
message?: string;
};

@@ -119,2 +177,3 @@ export interface ZodStringDef extends ZodTypeDef {

typeName: ZodFirstPartyTypeKind.ZodString;
coerce: boolean;
}

@@ -127,22 +186,51 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {

url(message?: errorUtil.ErrMessage): ZodString;
emoji(message?: errorUtil.ErrMessage): ZodString;
uuid(message?: errorUtil.ErrMessage): ZodString;
cuid(message?: errorUtil.ErrMessage): ZodString;
cuid2(message?: errorUtil.ErrMessage): ZodString;
ulid(message?: errorUtil.ErrMessage): ZodString;
ip(options?: string | {
version?: "v4" | "v6";
message?: string;
}): ZodString;
datetime(options?: string | {
message?: string | undefined;
precision?: number | null;
offset?: boolean;
}): ZodString;
regex(regex: RegExp, message?: errorUtil.ErrMessage): ZodString;
includes(value: string, options?: {
message?: string;
position?: number;
}): ZodString;
startsWith(value: string, message?: errorUtil.ErrMessage): ZodString;
endsWith(value: string, message?: errorUtil.ErrMessage): ZodString;
min(minLength: number, message?: errorUtil.ErrMessage): ZodString;
max(maxLength: number, message?: errorUtil.ErrMessage): ZodString;
length(len: number, message?: errorUtil.ErrMessage): ZodString;
/**
* Deprecated.
* Use z.string().min(1) instead.
*/
nonempty: (message?: errorUtil.ErrMessage | undefined) => ZodString;
trim: () => ZodString;
toLowerCase: () => ZodString;
toUpperCase: () => ZodString;
get isDatetime(): boolean;
get isEmail(): boolean;
get isURL(): boolean;
get isEmoji(): boolean;
get isUUID(): boolean;
get isCUID(): boolean;
get minLength(): number;
get maxLength(): null;
static create: (params?: RawCreateParams) => ZodString;
get isCUID2(): boolean;
get isULID(): boolean;
get isIP(): boolean;
get minLength(): number | null;
get maxLength(): number | null;
static create: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: true | undefined;
}) | undefined) => ZodString;
}
declare type ZodNumberCheck = {
export declare type ZodNumberCheck = {
kind: "min";

@@ -164,2 +252,5 @@ value: number;

message?: string;
} | {
kind: "finite";
message?: string;
};

@@ -169,6 +260,14 @@ export interface ZodNumberDef extends ZodTypeDef {

typeName: ZodFirstPartyTypeKind.ZodNumber;
coerce: boolean;
}
export declare class ZodNumber extends ZodType<number, ZodNumberDef> {
_parse(input: ParseInput): ParseReturnType<number>;
static create: (params?: RawCreateParams) => ZodNumber;
static create: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodNumber;
gte(value: number, message?: errorUtil.ErrMessage): ZodNumber;

@@ -189,21 +288,82 @@ min: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;

step: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
finite(message?: errorUtil.ErrMessage): ZodNumber;
safe(message?: errorUtil.ErrMessage): ZodNumber;
get minValue(): number | null;
get maxValue(): number | null;
get isInt(): boolean;
get isFinite(): boolean;
}
export declare type ZodBigIntCheck = {
kind: "min";
value: bigint;
inclusive: boolean;
message?: string;
} | {
kind: "max";
value: bigint;
inclusive: boolean;
message?: string;
} | {
kind: "multipleOf";
value: bigint;
message?: string;
};
export interface ZodBigIntDef extends ZodTypeDef {
checks: ZodBigIntCheck[];
typeName: ZodFirstPartyTypeKind.ZodBigInt;
coerce: boolean;
}
export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef> {
_parse(input: ParseInput): ParseReturnType<bigint>;
static create: (params?: RawCreateParams) => ZodBigInt;
static create: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodBigInt;
gte(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
min: (value: bigint, message?: errorUtil.ErrMessage | undefined) => ZodBigInt;
gt(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
lte(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
max: (value: bigint, message?: errorUtil.ErrMessage | undefined) => ZodBigInt;
lt(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
protected setLimit(kind: "min" | "max", value: bigint, inclusive: boolean, message?: string): ZodBigInt;
_addCheck(check: ZodBigIntCheck): ZodBigInt;
positive(message?: errorUtil.ErrMessage): ZodBigInt;
negative(message?: errorUtil.ErrMessage): ZodBigInt;
nonpositive(message?: errorUtil.ErrMessage): ZodBigInt;
nonnegative(message?: errorUtil.ErrMessage): ZodBigInt;
multipleOf(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
get minValue(): bigint | null;
get maxValue(): bigint | null;
}
export interface ZodBooleanDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodBoolean;
coerce: boolean;
}
export declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef> {
_parse(input: ParseInput): ParseReturnType<boolean>;
static create: (params?: RawCreateParams) => ZodBoolean;
static create: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodBoolean;
}
export declare type ZodDateCheck = {
kind: "min";
value: number;
message?: string;
} | {
kind: "max";
value: number;
message?: string;
};
export interface ZodDateDef extends ZodTypeDef {
checks: ZodDateCheck[];
coerce: boolean;
typeName: ZodFirstPartyTypeKind.ZodDate;

@@ -213,4 +373,23 @@ }

_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodDate;
_addCheck(check: ZodDateCheck): ZodDate;
min(minDate: Date, message?: errorUtil.ErrMessage): ZodDate;
max(maxDate: Date, message?: errorUtil.ErrMessage): ZodDate;
get minDate(): Date | null;
get maxDate(): Date | null;
static create: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodDate;
}
export interface ZodSymbolDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodSymbol;
}
export declare class ZodSymbol extends ZodType<symbol, ZodSymbolDef, symbol> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodSymbol;
}
export interface ZodUndefinedDef extends ZodTypeDef {

@@ -264,2 +443,6 @@ typeName: ZodFirstPartyTypeKind.ZodUndefined;

typeName: ZodFirstPartyTypeKind.ZodArray;
exactLength: {
value: number;
message?: string;
} | null;
minLength: {

@@ -275,3 +458,3 @@ value: number;

export declare type ArrayCardinality = "many" | "atleastone";
declare type arrayOutputType<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> = Cardinality extends "atleastone" ? [T["_output"], ...T["_output"][]] : T["_output"][];
export declare type arrayOutputType<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> = Cardinality extends "atleastone" ? [T["_output"], ...T["_output"][]] : T["_output"][];
export declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> extends ZodType<arrayOutputType<T, Cardinality>, ZodArrayDef<T>, Cardinality extends "atleastone" ? [T["_input"], ...T["_input"][]] : T["_input"][]> {

@@ -287,36 +470,3 @@ _parse(input: ParseInput): ParseReturnType<this["_output"]>;

export declare type ZodNonEmptyArray<T extends ZodTypeAny> = ZodArray<T, "atleastone">;
export declare namespace objectUtil {
export type MergeShapes<U extends ZodRawShape, V extends ZodRawShape> = {
[k in Exclude<keyof U, keyof V>]: U[k];
} & V;
type optionalKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];
type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>;
export type addQuestionMarks<T extends object> = {
[k in optionalKeys<T>]?: T[k];
} & {
[k in requiredKeys<T>]: T[k];
};
export type identity<T> = T;
export type flatten<T extends object> = identity<{
[k in keyof T]: T[k];
}>;
export type noNeverKeys<T extends ZodRawShape> = {
[k in keyof T]: [T[k]] extends [never] ? never : k;
}[keyof T];
export type noNever<T extends ZodRawShape> = identity<{
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
}>;
export const mergeShapes: <U extends ZodRawShape, T extends ZodRawShape>(first: U, second: T) => T & U;
export {};
}
export declare type extendShape<A, B> = {
[k in Exclude<keyof A, keyof B>]: A[k];
} & {
[k in keyof B]: B[k];
};
declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
export declare type Primitive = string | number | bigint | boolean | null | undefined;
export declare type Scalars = Primitive | Primitive[];
export declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
export interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {

@@ -328,20 +478,28 @@ typeName: ZodFirstPartyTypeKind.ZodObject;

}
export declare type baseObjectOutputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
export declare type mergeTypes<A, B> = {
[k in keyof A | keyof B]: k extends keyof B ? B[k] : k extends keyof A ? A[k] : never;
};
export declare type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<objectUtil.addQuestionMarks<baseObjectOutputType<Shape>>> & CatchallOutput<Catchall> & PassthroughType<UnknownKeys>;
export declare type baseObjectOutputType<Shape extends ZodRawShape> = {
[k in keyof Shape]: Shape[k]["_output"];
}>>;
export declare type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? baseObjectOutputType<Shape> : objectUtil.flatten<baseObjectOutputType<Shape> & {
[k: string]: Catchall["_output"];
}>;
export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
};
export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<baseObjectInputType<Shape>> & CatchallInput<Catchall> & PassthroughType<UnknownKeys>;
export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]["_input"];
}>>;
export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? baseObjectInputType<Shape> : objectUtil.flatten<baseObjectInputType<Shape> & {
[k: string]: Catchall["_input"];
}>;
declare type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T;
export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny, any, any>;
export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
readonly _shape: T;
readonly _unknownKeys: UnknownKeys;
readonly _catchall: Catchall;
export declare type CatchallOutput<T extends ZodTypeAny> = ZodTypeAny extends T ? unknown : {
[k: string]: T["_output"];
};
export declare type CatchallInput<T extends ZodTypeAny> = ZodTypeAny extends T ? unknown : {
[k: string]: T["_input"];
};
export declare type PassthroughType<T extends UnknownKeysParam> = T extends "passthrough" ? {
[k: string]: unknown;
} : unknown;
export declare type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T extends ZodNullable<infer U> ? ZodNullable<deoptional<U>> : T;
export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny>;
export declare type noUnrecognized<Obj extends object, Shape extends object> = {
[k in keyof Obj]: k extends keyof Shape ? Obj[k] : never;
};
export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
private _cached;

@@ -357,29 +515,16 @@ _getCached(): {

passthrough(): ZodObject<T, "passthrough", Catchall>;
/**
* @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
* If you want to pass through unknown properties, use `.passthrough()` instead.
*/
nonstrict: () => ZodObject<T, "passthrough", Catchall>;
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<extendShape<T, Augmentation>, UnknownKeys, Catchall, objectOutputType<extendShape<T, Augmentation>, Catchall>, objectInputType<extendShape<T, Augmentation>, Catchall>>;
extend: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<extendShape<T, Augmentation>, UnknownKeys, Catchall, objectOutputType<extendShape<T, Augmentation>, Catchall>, objectInputType<extendShape<T, Augmentation>, Catchall>>;
extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, UnknownKeys, Catchall, objectOutputType<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, Catchall, UnknownKeys>, objectInputType<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, Catchall, UnknownKeys>>;
merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & {
[k in Key]: Schema;
}, UnknownKeys, Catchall>;
/**
* Prior to zod@1.0.12 there was a bug in the
* inferred type of merged objects. Please
* upgrade if you are experiencing issues.
*/
merge<Incoming extends AnyZodObject>(merging: Incoming): ZodObject<extendShape<T, Incoming["_shape"]>, UnknownKeys, Catchall>;
catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
pick<Mask extends {
[k in keyof T]?: true;
}>(mask: Mask): ZodObject<objectUtil.noNever<{
[k in keyof Mask]: k extends keyof T ? T[k] : never;
}>, UnknownKeys, Catchall>;
}>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
omit<Mask extends {
[k in keyof T]?: true;
}>(mask: Mask): ZodObject<objectUtil.noNever<{
[k in keyof T]: k extends keyof Mask ? never : T[k];
}>, UnknownKeys, Catchall>;
}>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
deepPartial(): partialUtil.DeepPartial<this>;

@@ -397,9 +542,19 @@ partial(): ZodObject<{

}, UnknownKeys, Catchall>;
static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>[k_3]; }>;
static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>[k_3]; }>;
static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>[k_3]; }>;
required<Mask extends {
[k in keyof T]?: true;
}>(mask: Mask): ZodObject<objectUtil.noNever<{
[k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
}>, UnknownKeys, Catchall>;
keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_2]; }>;
static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_2]; }>;
static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_2]; }>;
}
export declare type AnyZodObject = ZodObject<any, any, any>;
declare type ZodUnionOptions = [ZodTypeAny, ...ZodTypeAny[]];
export interface ZodUnionDef<T extends ZodUnionOptions = [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]> extends ZodTypeDef {
export declare type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
export interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[
ZodTypeAny,
ZodTypeAny,
...ZodTypeAny[]
]>> extends ZodTypeDef {
options: T;

@@ -411,4 +566,23 @@ typeName: ZodFirstPartyTypeKind.ZodUnion;

get options(): T;
static create: <T_1 extends [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T_1, params?: RawCreateParams) => ZodUnion<T_1>;
static create: <T_1 extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T_1, params?: RawCreateParams) => ZodUnion<T_1>;
}
export declare type ZodDiscriminatedUnionOption<Discriminator extends string> = ZodObject<{
[key in Discriminator]: ZodTypeAny;
} & ZodRawShape, UnknownKeysParam, ZodTypeAny>;
export interface ZodDiscriminatedUnionDef<Discriminator extends string, Options extends ZodDiscriminatedUnionOption<string>[] = ZodDiscriminatedUnionOption<string>[]> extends ZodTypeDef {
discriminator: Discriminator;
options: Options;
optionsMap: Map<Primitive, ZodDiscriminatedUnionOption<any>>;
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion;
}
export declare class ZodDiscriminatedUnion<Discriminator extends string, Options extends ZodDiscriminatedUnionOption<Discriminator>[]> extends ZodType<output<Options[number]>, ZodDiscriminatedUnionDef<Discriminator, Options>, input<Options[number]>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get discriminator(): Discriminator;
get options(): Options;
get optionsMap(): Map<Primitive, ZodDiscriminatedUnionOption<any>>;
static create<Discriminator extends string, Types extends [
ZodDiscriminatedUnionOption<Discriminator>,
...ZodDiscriminatedUnionOption<Discriminator>[]
]>(discriminator: Discriminator, options: Types, params?: RawCreateParams): ZodDiscriminatedUnion<Discriminator, Types>;
}
export interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {

@@ -424,3 +598,3 @@ left: T;

export declare type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
export declare type AssertArray<T extends any> = T extends any[] ? T : never;
export declare type AssertArray<T> = T extends any[] ? T : never;
export declare type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{

@@ -439,2 +613,6 @@ [k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;

}
export declare type AnyZodTuple = ZodTuple<[
ZodTypeAny,
...ZodTypeAny[]
] | [], ZodTypeAny | null>;
export declare class ZodTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]], Rest extends ZodTypeAny | null = null> extends ZodType<OutputTypeOfTupleWithRest<T, Rest>, ZodTupleDef<T, Rest>, InputTypeOfTupleWithRest<T, Rest>> {

@@ -444,3 +622,3 @@ _parse(input: ParseInput): ParseReturnType<this["_output"]>;

rest<Rest extends ZodTypeAny>(rest: Rest): ZodTuple<T, Rest>;
static create: <T_1 extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: T_1, params?: RawCreateParams) => ZodTuple<T_1, null>;
static create: <T_1 extends [] | [ZodTypeAny, ...ZodTypeAny[]]>(schemas: T_1, params?: RawCreateParams) => ZodTuple<T_1, null>;
}

@@ -452,4 +630,7 @@ export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {

}
declare type KeySchema = ZodType<string | number | symbol, any, any>;
export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Record<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, Record<Key["_input"], Value["_input"]>> {
export declare type KeySchema = ZodType<string | number | symbol, any, any>;
export declare type RecordType<K extends string | number | symbol, V> = [
string
] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : [BRAND<string | number | symbol>] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<RecordType<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, RecordType<Key["_input"], Value["_input"]>> {
get keySchema(): Key;

@@ -468,2 +649,4 @@ get valueSchema(): Value;

export declare class ZodMap<Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Map<Key["_output"], Value["_output"]>, ZodMapDef<Key, Value>, Map<Key["_input"], Value["_input"]>> {
get keySchema(): Key;
get valueSchema(): Value;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;

@@ -475,5 +658,17 @@ static create: <Key_1 extends ZodTypeAny = ZodTypeAny, Value_1 extends ZodTypeAny = ZodTypeAny>(keyType: Key_1, valueType: Value_1, params?: RawCreateParams) => ZodMap<Key_1, Value_1>;

typeName: ZodFirstPartyTypeKind.ZodSet;
minSize: {
value: number;
message?: string;
} | null;
maxSize: {
value: number;
message?: string;
} | null;
}
export declare class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Set<Value["_output"]>, ZodSetDef<Value>, Set<Value["_input"]>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
min(minSize: number, message?: errorUtil.ErrMessage): this;
max(maxSize: number, message?: errorUtil.ErrMessage): this;
size(size: number, message?: errorUtil.ErrMessage): this;
nonempty(message?: errorUtil.ErrMessage): ZodSet<Value>;
static create: <Value_1 extends ZodTypeAny = ZodTypeAny>(valueType: Value_1, params?: RawCreateParams) => ZodSet<Value_1>;

@@ -492,8 +687,11 @@ }

returnType(): Returns;
args<Items extends Parameters<typeof ZodTuple["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
args<Items extends Parameters<(typeof ZodTuple)["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
returns<NewReturnType extends ZodType<any, any>>(returnType: NewReturnType): ZodFunction<Args, NewReturnType>;
implement<F extends InnerTypeOfFunction<Args, Returns>>(func: F): F;
implement<F extends InnerTypeOfFunction<Args, Returns>>(func: F): ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
strictImplement(func: InnerTypeOfFunction<Args, Returns>): InnerTypeOfFunction<Args, Returns>;
validate: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => F;
static create: <T extends ZodTuple<any, any> = ZodTuple<[], ZodUnknown>, U extends ZodTypeAny = ZodUnknown>(args?: T | undefined, returns?: U | undefined, params?: RawCreateParams) => ZodFunction<T, U>;
validate: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
static create(): ZodFunction<ZodTuple<[], ZodUnknown>, ZodUnknown>;
static create<T extends AnyZodTuple = ZodTuple<[], ZodUnknown>>(args: T): ZodFunction<T, ZodUnknown>;
static create<T extends AnyZodTuple, U extends ZodTypeAny>(args: T, returns: U): ZodFunction<T, U>;
static create<T extends AnyZodTuple = ZodTuple<[], ZodUnknown>, U extends ZodTypeAny = ZodUnknown>(args: T, returns: U, params?: RawCreateParams): ZodFunction<T, U>;
}

@@ -509,7 +707,7 @@ export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {

}
export interface ZodLiteralDef<T extends any = any> extends ZodTypeDef {
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
value: T;
typeName: ZodFirstPartyTypeKind.ZodLiteral;
}
export declare class ZodLiteral<T extends any> extends ZodType<T, ZodLiteralDef<T>> {
export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;

@@ -521,4 +719,4 @@ get value(): T;

export declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
declare type EnumValues = [string, ...string[]];
declare type Values<T extends EnumValues> = {
export declare type EnumValues = [string, ...string[]];
export declare type Values<T extends EnumValues> = {
[k in T[number]]: k;

@@ -530,7 +728,9 @@ };

}
declare type Writeable<T> = {
export declare type Writeable<T> = {
-readonly [P in keyof T]: T[P];
};
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T): ZodEnum<Writeable<T>>;
declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T): ZodEnum<T>;
export declare type FilterEnum<Values, ToExclude> = Values extends [] ? [] : Values extends [infer Head, ...infer Rest] ? Head extends ToExclude ? FilterEnum<Rest, ToExclude> : [Head, ...FilterEnum<Rest, ToExclude>] : never;
export declare type typecast<A, T> = A extends T ? A : never;
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T, params?: RawCreateParams): ZodEnum<Writeable<T>>;
declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T, params?: RawCreateParams): ZodEnum<T>;
export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>> {

@@ -542,2 +742,4 @@ _parse(input: ParseInput): ParseReturnType<this["_output"]>;

get Enum(): Values<T>;
extract<ToExtract extends readonly [T[number], ...T[number][]]>(values: ToExtract): ZodEnum<Writeable<ToExtract>>;
exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude): ZodEnum<typecast<Writeable<FilterEnum<T, ToExclude[number]>>, [string, ...string[]]>>;
static create: typeof createZodEnum;

@@ -549,3 +751,3 @@ }

}
declare type EnumLike = {
export declare type EnumLike = {
[k: string]: string | number;

@@ -556,2 +758,3 @@ [nu: number]: string;

_parse(input: ParseInput): ParseReturnType<T[keyof T]>;
get enum(): T;
static create: <T_1 extends EnumLike>(values: T_1, params?: RawCreateParams) => ZodNativeEnum<T_1>;

@@ -564,2 +767,3 @@ }

export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
unwrap(): T;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;

@@ -569,3 +773,3 @@ static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodPromise<T_1>;

export declare type Refinement<T> = (arg: T, ctx: RefinementCtx) => any;
export declare type SuperRefinement<T> = (arg: T, ctx: RefinementCtx) => void;
export declare type SuperRefinement<T> = (arg: T, ctx: RefinementCtx) => void | Promise<void>;
export declare type RefinementEffect<T> = {

@@ -577,7 +781,7 @@ type: "refinement";

type: "transform";
transform: (arg: T) => any;
transform: (arg: T, ctx: RefinementCtx) => any;
};
export declare type PreprocessEffect<T> = {
type: "preprocess";
transform: (arg: T) => any;
transform: (arg: T, ctx: RefinementCtx) => any;
};

@@ -590,7 +794,8 @@ export declare type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEffect<T>;

}
export declare class ZodEffects<T extends ZodTypeAny, Output = T["_output"], Input = T["_input"]> extends ZodType<Output, ZodEffectsDef<T>, Input> {
export declare class ZodEffects<T extends ZodTypeAny, Output = output<T>, Input = input<T>> extends ZodType<Output, ZodEffectsDef<T>, Input> {
innerType(): T;
sourceType(): T;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], input<I>>;
static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
}

@@ -626,8 +831,80 @@ export { ZodEffects as ZodTransformer };

removeDefault(): T;
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodOptional<T_1>;
static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
default: T_1["_input"] | (() => util.noUndefined<T_1["_input"]>);
}) => ZodDefault<T_1>;
}
export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<T, ZodTypeDef, T>;
export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
innerType: T;
catchValue: (ctx: {
error: ZodError;
input: unknown;
}) => T["_input"];
typeName: ZodFirstPartyTypeKind.ZodCatch;
}
export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
removeCatch(): T;
static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
catch: T_1["_output"] | (() => T_1["_output"]);
}) => ZodCatch<T_1>;
}
export interface ZodNaNDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodNaN;
}
export declare class ZodNaN extends ZodType<number, ZodNaNDef> {
_parse(input: ParseInput): ParseReturnType<any>;
static create: (params?: RawCreateParams) => ZodNaN;
}
export interface ZodBrandedDef<T extends ZodTypeAny> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodBranded;
}
export declare const BRAND: unique symbol;
export declare type BRAND<T extends string | number | symbol> = {
[BRAND]: {
[k in T]: true;
};
};
export declare class ZodBranded<T extends ZodTypeAny, B extends string | number | symbol> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
_parse(input: ParseInput): ParseReturnType<any>;
unwrap(): T;
}
export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodTypeDef {
in: A;
out: B;
typeName: ZodFirstPartyTypeKind.ZodPipeline;
}
export declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
_parse(input: ParseInput): ParseReturnType<any>;
static create<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodPipeline<A, B>;
}
declare type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
readonly [Symbol.toStringTag]: string;
} | Date | Error | Generator | Promise<unknown> | RegExp;
declare type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodReadonly;
}
export declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, T["_input"]> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodReadonly<T_1>;
}
declare type CustomParams = CustomErrorParams & {
fatal?: boolean;
};
export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: string | CustomParams | ((input: any) => CustomParams), fatal?: boolean | undefined) => ZodType<T, ZodTypeDef, T>;
export { ZodType as Schema, ZodType as ZodSchema };
export declare const late: {
object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_2]; }>;
};

@@ -637,5 +914,7 @@ export declare enum ZodFirstPartyTypeKind {

ZodNumber = "ZodNumber",
ZodNaN = "ZodNaN",
ZodBigInt = "ZodBigInt",
ZodBoolean = "ZodBoolean",
ZodDate = "ZodDate",
ZodSymbol = "ZodSymbol",
ZodUndefined = "ZodUndefined",

@@ -650,2 +929,3 @@ ZodNull = "ZodNull",

ZodUnion = "ZodUnion",
ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
ZodIntersection = "ZodIntersection",

@@ -665,11 +945,55 @@ ZodTuple = "ZodTuple",

ZodDefault = "ZodDefault",
ZodPromise = "ZodPromise"
ZodCatch = "ZodCatch",
ZodPromise = "ZodPromise",
ZodBranded = "ZodBranded",
ZodPipeline = "ZodPipeline",
ZodReadonly = "ZodReadonly"
}
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any, any, any> | ZodUnion<any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodPromise<any>;
declare const instanceOfType: <T extends new (...args: any[]) => any>(cls: T, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
declare const stringType: (params?: RawCreateParams) => ZodString;
declare const numberType: (params?: RawCreateParams) => ZodNumber;
declare const bigIntType: (params?: RawCreateParams) => ZodBigInt;
declare const booleanType: (params?: RawCreateParams) => ZodBoolean;
declare const dateType: (params?: RawCreateParams) => ZodDate;
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<any, any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodCatch<any> | ZodPromise<any> | ZodBranded<any, any> | ZodPipeline<any, any>;
declare abstract class Class {
constructor(..._: any[]);
}
declare const instanceOfType: <T extends typeof Class>(cls: T, params?: CustomParams) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
declare const stringType: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: true | undefined;
}) | undefined) => ZodString;
declare const numberType: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodNumber;
declare const nanType: (params?: RawCreateParams) => ZodNaN;
declare const bigIntType: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodBigInt;
declare const booleanType: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodBoolean;
declare const dateType: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodDate;
declare const symbolType: (params?: RawCreateParams) => ZodSymbol;
declare const undefinedType: (params?: RawCreateParams) => ZodUndefined;

@@ -682,11 +1006,12 @@ declare const nullType: (params?: RawCreateParams) => ZodNull;

declare const arrayType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodArray<T, "many">;
declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
declare const unionType: <T extends [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T, params?: RawCreateParams) => ZodUnion<T>;
declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_2]; }>;
declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_2]; }>;
declare const unionType: <T extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T, params?: RawCreateParams) => ZodUnion<T>;
declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
declare const intersectionType: <T extends ZodTypeAny, U extends ZodTypeAny>(left: T, right: U, params?: RawCreateParams) => ZodIntersection<T, U>;
declare const tupleType: <T extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: T, params?: RawCreateParams) => ZodTuple<T, null>;
declare const tupleType: <T extends [] | [ZodTypeAny, ...ZodTypeAny[]]>(schemas: T, params?: RawCreateParams) => ZodTuple<T, null>;
declare const recordType: typeof ZodRecord.create;
declare const mapType: <Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny>(keyType: Key, valueType: Value, params?: RawCreateParams) => ZodMap<Key, Value>;
declare const setType: <Value extends ZodTypeAny = ZodTypeAny>(valueType: Value, params?: RawCreateParams) => ZodSet<Value>;
declare const functionType: <T extends ZodTuple<any, any> = ZodTuple<[], ZodUnknown>, U extends ZodTypeAny = ZodUnknown>(args?: T | undefined, returns?: U | undefined, params?: RawCreateParams) => ZodFunction<T, U>;
declare const functionType: typeof ZodFunction.create;
declare const lazyType: <T extends ZodTypeAny>(getter: () => T, params?: RawCreateParams) => ZodLazy<T>;

@@ -697,10 +1022,53 @@ declare const literalType: <T extends Primitive>(value: T, params?: RawCreateParams) => ZodLiteral<T>;

declare const promiseType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodPromise<T>;
declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], input<I>>;
declare const optionalType: <T extends ZodTypeAny>(type: T, params?: RawCreateParams) => ZodOptional<T>;
declare const nullableType: <T extends ZodTypeAny>(type: T, params?: RawCreateParams) => ZodNullable<T>;
declare const preprocessType: <I extends ZodTypeAny>(preprocess: (arg: unknown) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
declare const preprocessType: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
declare const pipelineType: typeof ZodPipeline.create;
declare const ostring: () => ZodOptional<ZodString>;
declare const onumber: () => ZodOptional<ZodNumber>;
declare const oboolean: () => ZodOptional<ZodBoolean>;
export { anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, dateType as date, effectsType as effect, enumType as enum, functionType as function, instanceOfType as instanceof, intersectionType as intersection, lazyType as lazy, literalType as literal, mapType as map, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, oboolean, onumber, optionalType as optional, ostring, preprocessType as preprocess, promiseType as promise, recordType as record, setType as set, strictObjectType as strictObject, stringType as string, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, };
//# sourceMappingURL=types.d.ts.map
export declare const coerce: {
string: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: true | undefined;
}) | undefined) => ZodString;
number: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodNumber;
boolean: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodBoolean;
bigint: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodBigInt;
date: (params?: ({
errorMap?: ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: boolean | undefined;
}) | undefined) => ZodDate;
};
export { anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, dateType as date, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, instanceOfType as instanceof, intersectionType as intersection, lazyType as lazy, literalType as literal, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, recordType as record, setType as set, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, };
export declare const NEVER: never;

@@ -1,7 +0,18 @@

import { ZodParsedType } from "./helpers/parseUtil";
import { util } from "./helpers/util";
import type { TypeOf, ZodType } from ".";
import { Primitive } from "./helpers/typeAliases";
import { util, ZodParsedType } from "./helpers/util";
declare type allKeys<T> = T extends any ? keyof T : never;
export declare type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
export declare type typeToFlattenedError<T, U = string> = {
formErrors: U[];
fieldErrors: {
[P in allKeys<T>]?: U[];
};
};
export declare const ZodIssueCode: {
invalid_type: "invalid_type";
invalid_literal: "invalid_literal";
custom: "custom";
invalid_union: "invalid_union";
invalid_union_discriminator: "invalid_union_discriminator";
invalid_enum_value: "invalid_enum_value";

@@ -17,2 +28,3 @@ unrecognized_keys: "unrecognized_keys";

not_multiple_of: "not_multiple_of";
not_finite: "not_finite";
};

@@ -29,2 +41,7 @@ export declare type ZodIssueCode = keyof typeof ZodIssueCode;

}
export interface ZodInvalidLiteralIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_literal;
expected: unknown;
received: unknown;
}
export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {

@@ -38,3 +55,8 @@ code: typeof ZodIssueCode.unrecognized_keys;

}
export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_union_discriminator;
options: Primitive[];
}
export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
received: string | number;
code: typeof ZodIssueCode.invalid_enum_value;

@@ -54,3 +76,10 @@ options: (string | number)[];

}
export declare type StringValidation = "email" | "url" | "uuid" | "regex" | "cuid";
export declare type StringValidation = "email" | "url" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | {
includes: string;
position?: number;
} | {
startsWith: string;
} | {
endsWith: string;
};
export interface ZodInvalidStringIssue extends ZodIssueBase {

@@ -62,11 +91,13 @@ code: typeof ZodIssueCode.invalid_string;

code: typeof ZodIssueCode.too_small;
minimum: number;
minimum: number | bigint;
inclusive: boolean;
type: "array" | "string" | "number";
exact?: boolean;
type: "array" | "string" | "number" | "set" | "date" | "bigint";
}
export interface ZodTooBigIssue extends ZodIssueBase {
code: typeof ZodIssueCode.too_big;
maximum: number;
maximum: number | bigint;
inclusive: boolean;
type: "array" | "string" | "number";
exact?: boolean;
type: "array" | "string" | "number" | "set" | "date" | "bigint";
}

@@ -78,4 +109,7 @@ export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {

code: typeof ZodIssueCode.not_multiple_of;
multipleOf: number;
multipleOf: number | bigint;
}
export interface ZodNotFiniteIssue extends ZodIssueBase {
code: typeof ZodIssueCode.not_finite;
}
export interface ZodCustomIssue extends ZodIssueBase {

@@ -90,14 +124,19 @@ code: typeof ZodIssueCode.custom;

};
export declare type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodCustomIssue;
export declare type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;
export declare type ZodIssue = ZodIssueOptionalMessage & {
fatal?: boolean;
message: string;
};
export declare const quotelessJson: (obj: any) => string;
export declare type ZodFormattedError<T> = {
_errors: string[];
} & (T extends [any, ...any[]] ? {
declare type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? {
[K in keyof T]?: ZodFormattedError<T[K]>;
} : T extends any[] ? ZodFormattedError<T[number]>[] : T extends object ? {
} : T extends any[] ? {
[k: number]: ZodFormattedError<T[number]>;
} : T extends object ? {
[K in keyof T]?: ZodFormattedError<T[K]>;
} : unknown);
} : unknown;
export declare type ZodFormattedError<T, U = string> = {
_errors: U[];
} & recursiveZodFormattedError<NonNullable<T>>;
export declare type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;
export declare class ZodError<T = any> extends Error {

@@ -107,3 +146,4 @@ issues: ZodIssue[];

constructor(issues: ZodIssue[]);
format: () => ZodFormattedError<T>;
format(): ZodFormattedError<T>;
format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
static create: (issues: ZodIssue[]) => ZodError<any>;

@@ -115,14 +155,5 @@ toString(): string;

addIssues: (subs?: ZodIssue[]) => void;
flatten: <U = string>(mapper?: (issue: ZodIssue) => U) => {
formErrors: U[];
fieldErrors: {
[k: string]: U[];
};
};
get formErrors(): {
formErrors: string[];
fieldErrors: {
[k: string]: string[];
};
};
flatten(): typeToFlattenedError<T>;
flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
get formErrors(): typeToFlattenedError<T, string>;
}

@@ -134,16 +165,9 @@ declare type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;

};
export declare type MakeErrorData = IssueData;
declare type ErrorMapCtx = {
export declare type ErrorMapCtx = {
defaultError: string;
data: any;
};
export declare type ZodErrorMap = typeof defaultErrorMap;
export declare const defaultErrorMap: (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
export declare type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
message: string;
};
export declare let overrideErrorMap: (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
message: string;
};
export declare const setErrorMap: (map: ZodErrorMap) => void;
export {};
//# sourceMappingURL=ZodError.d.ts.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setErrorMap = exports.overrideErrorMap = exports.defaultErrorMap = exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
var util_1 = require("./helpers/util");
exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
const util_1 = require("./helpers/util");
exports.ZodIssueCode = util_1.util.arrayToEnum([
"invalid_type",
"invalid_literal",
"custom",
"invalid_union",
"invalid_union_discriminator",
"invalid_enum_value",

@@ -70,233 +21,105 @@ "unrecognized_keys",

"not_multiple_of",
"not_finite",
]);
var quotelessJson = function (obj) {
var json = JSON.stringify(obj, null, 2);
const quotelessJson = (obj) => {
const json = JSON.stringify(obj, null, 2);
return json.replace(/"([^"]+)":/g, "$1:");
};
exports.quotelessJson = quotelessJson;
var ZodError = /** @class */ (function (_super) {
__extends(ZodError, _super);
function ZodError(issues) {
var _newTarget = this.constructor;
var _this = _super.call(this) || this;
_this.issues = [];
_this.format = function () {
var fieldErrors = { _errors: [] };
var processError = function (error) {
var e_1, _a;
try {
for (var _b = __values(error.issues), _c = _b.next(); !_c.done; _c = _b.next()) {
var issue = _c.value;
if (issue.code === "invalid_union") {
issue.unionErrors.map(processError);
class ZodError extends Error {
constructor(issues) {
super();
this.issues = [];
this.addIssue = (sub) => {
this.issues = [...this.issues, sub];
};
this.addIssues = (subs = []) => {
this.issues = [...this.issues, ...subs];
};
const actualProto = new.target.prototype;
if (Object.setPrototypeOf) {
Object.setPrototypeOf(this, actualProto);
}
else {
this.__proto__ = actualProto;
}
this.name = "ZodError";
this.issues = issues;
}
get errors() {
return this.issues;
}
format(_mapper) {
const mapper = _mapper ||
function (issue) {
return issue.message;
};
const fieldErrors = { _errors: [] };
const processError = (error) => {
for (const issue of error.issues) {
if (issue.code === "invalid_union") {
issue.unionErrors.map(processError);
}
else if (issue.code === "invalid_return_type") {
processError(issue.returnTypeError);
}
else if (issue.code === "invalid_arguments") {
processError(issue.argumentsError);
}
else if (issue.path.length === 0) {
fieldErrors._errors.push(mapper(issue));
}
else {
let curr = fieldErrors;
let i = 0;
while (i < issue.path.length) {
const el = issue.path[i];
const terminal = i === issue.path.length - 1;
if (!terminal) {
curr[el] = curr[el] || { _errors: [] };
}
else if (issue.code === "invalid_return_type") {
processError(issue.returnTypeError);
}
else if (issue.code === "invalid_arguments") {
processError(issue.argumentsError);
}
else if (issue.path.length === 0) {
fieldErrors._errors.push(issue.message);
}
else {
var curr = fieldErrors;
var i = 0;
while (i < issue.path.length) {
var el = issue.path[i];
var terminal = i === issue.path.length - 1;
if (!terminal) {
if (typeof el === "string") {
curr[el] = curr[el] || { _errors: [] };
}
else if (typeof el === "number") {
var errorArray = [];
errorArray._errors = [];
curr[el] = curr[el] || errorArray;
}
}
else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(issue.message);
}
curr = curr[el];
i++;
}
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(mapper(issue));
}
curr = curr[el];
i++;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
processError(_this);
return fieldErrors;
};
_this.addIssue = function (sub) {
_this.issues = __spreadArray(__spreadArray([], __read(_this.issues), false), [sub], false);
};
_this.addIssues = function (subs) {
if (subs === void 0) { subs = []; }
_this.issues = __spreadArray(__spreadArray([], __read(_this.issues), false), __read(subs), false);
};
_this.flatten = function (mapper) {
var e_2, _a;
if (mapper === void 0) { mapper = function (issue) { return issue.message; }; }
var fieldErrors = {};
var formErrors = [];
try {
for (var _b = __values(_this.issues), _c = _b.next(); !_c.done; _c = _b.next()) {
var sub = _c.value;
if (sub.path.length > 0) {
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
fieldErrors[sub.path[0]].push(mapper(sub));
}
else {
formErrors.push(mapper(sub));
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
return { formErrors: formErrors, fieldErrors: fieldErrors };
};
var actualProto = _newTarget.prototype;
if (Object.setPrototypeOf) {
// eslint-disable-next-line ban/ban
Object.setPrototypeOf(_this, actualProto);
}
else {
_this.__proto__ = actualProto;
}
_this.name = "ZodError";
_this.issues = issues;
return _this;
processError(this);
return fieldErrors;
}
Object.defineProperty(ZodError.prototype, "errors", {
get: function () {
return this.issues;
},
enumerable: false,
configurable: true
});
ZodError.prototype.toString = function () {
toString() {
return this.message;
};
Object.defineProperty(ZodError.prototype, "message", {
get: function () {
return JSON.stringify(this.issues, null, 2);
},
enumerable: false,
configurable: true
});
Object.defineProperty(ZodError.prototype, "isEmpty", {
get: function () {
return this.issues.length === 0;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ZodError.prototype, "formErrors", {
get: function () {
return this.flatten();
},
enumerable: false,
configurable: true
});
ZodError.create = function (issues) {
var error = new ZodError(issues);
return error;
};
return ZodError;
}(Error));
exports.ZodError = ZodError;
var defaultErrorMap = function (issue, _ctx) {
var message;
switch (issue.code) {
case exports.ZodIssueCode.invalid_type:
if (issue.received === "undefined") {
message = "Required";
}
get message() {
return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2);
}
get isEmpty() {
return this.issues.length === 0;
}
flatten(mapper = (issue) => issue.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of this.issues) {
if (sub.path.length > 0) {
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
fieldErrors[sub.path[0]].push(mapper(sub));
}
else {
message = "Expected " + issue.expected + ", received " + issue.received;
formErrors.push(mapper(sub));
}
break;
case exports.ZodIssueCode.unrecognized_keys:
message = "Unrecognized key(s) in object: " + issue.keys
.map(function (k) { return "'" + k + "'"; })
.join(", ");
break;
case exports.ZodIssueCode.invalid_union:
message = "Invalid input";
break;
case exports.ZodIssueCode.invalid_enum_value:
message = "Invalid enum value. Expected " + issue.options
.map(function (val) { return (typeof val === "string" ? "'" + val + "'" : val); })
.join(" | ") + ", received " + (typeof _ctx.data === "string" ? "'" + _ctx.data + "'" : _ctx.data);
break;
case exports.ZodIssueCode.invalid_arguments:
message = "Invalid function arguments";
break;
case exports.ZodIssueCode.invalid_return_type:
message = "Invalid function return type";
break;
case exports.ZodIssueCode.invalid_date:
message = "Invalid date";
break;
case exports.ZodIssueCode.invalid_string:
if (issue.validation !== "regex")
message = "Invalid " + issue.validation;
else
message = "Invalid";
break;
case exports.ZodIssueCode.too_small:
if (issue.type === "array")
message = "Should have " + (issue.inclusive ? "at least" : "more than") + " " + issue.minimum + " items";
else if (issue.type === "string")
message = "Should be " + (issue.inclusive ? "at least" : "over") + " " + issue.minimum + " characters";
else if (issue.type === "number")
message = "Value should be greater than " + (issue.inclusive ? "or equal to " : "") + issue.minimum;
else
message = "Invalid input";
break;
case exports.ZodIssueCode.too_big:
if (issue.type === "array")
message = "Should have " + (issue.inclusive ? "at most" : "less than") + " " + issue.maximum + " items";
else if (issue.type === "string")
message = "Should be " + (issue.inclusive ? "at most" : "under") + " " + issue.maximum + " characters long";
else if (issue.type === "number")
message = "Value should be less than " + (issue.inclusive ? "or equal to " : "") + issue.maximum;
else
message = "Invalid input";
break;
case exports.ZodIssueCode.custom:
message = "Invalid input";
break;
case exports.ZodIssueCode.invalid_intersection_types:
message = "Intersection results could not be merged";
break;
case exports.ZodIssueCode.not_multiple_of:
message = "Should be multiple of " + issue.multipleOf;
break;
default:
message = _ctx.defaultError;
util_1.util.assertNever(issue);
}
return { formErrors, fieldErrors };
}
return { message: message };
get formErrors() {
return this.flatten();
}
}
exports.ZodError = ZodError;
ZodError.create = (issues) => {
const error = new ZodError(issues);
return error;
};
exports.defaultErrorMap = defaultErrorMap;
exports.overrideErrorMap = exports.defaultErrorMap;
var setErrorMap = function (map) {
exports.overrideErrorMap = map;
};
exports.setErrorMap = setErrorMap;
//# sourceMappingURL=ZodError.js.map
{
"name": "zod",
"version": "3.11.6",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"version": "3.22.3",
"author": "Colin McDonnell <colin@colinhacks.com>",
"repository": {
"type": "git",
"url": "https://github.com/colinhacks/zod"
},
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"module": "./lib/index.mjs",
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@rollup/plugin-typescript": "^8.2.0",
"@swc/core": "^1.3.66",
"@swc/jest": "^0.2.26",
"@types/benchmark": "^2.1.0",
"@types/jest": "^29.2.2",
"@types/node": "14",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"babel-jest": "^29.5.0",
"benchmark": "^2.1.4",
"dependency-cruiser": "^9.19.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-ban": "^1.6.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^7.0.4",
"jest": "^29.3.1",
"lint-staged": "^12.3.7",
"nodemon": "^2.0.15",
"prettier": "^2.6.0",
"pretty-quick": "^3.1.3",
"rollup": "^2.70.1",
"ts-jest": "^29.1.0",
"ts-morph": "^14.0.0",
"ts-node": "^10.9.1",
"tslib": "^2.3.1",
"tsx": "^3.8.0",
"typescript": "~4.5.0",
"vitest": "^0.32.2"
},
"exports": {
".": {
"types": "./index.d.ts",
"require": "./lib/index.js",
"import": "./lib/index.mjs"
},
"./package.json": "./package.json"
"./package.json": "./package.json",
"./locales/*": "./lib/locales/*"
},
"files": [
"/lib"
],
"repository": {
"type": "git",
"url": "https://github.com/colinhacks/zod"
},
"author": "Colin McDonnell <colin@colinhacks.com>",
"license": "MIT",
"sideEffects": false,
"bugs": {
"url": "https://github.com/colinhacks/zod/issues"
},
"homepage": "https://github.com/colinhacks/zod",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"files": [
"/lib",
"/index.d.ts"
],
"funding": "https://github.com/sponsors/colinhacks",
"support": {
"backing": {
"npm-funding": true
}
},
"homepage": "https://zod.dev",
"keywords": [

@@ -42,65 +73,48 @@ "typescript",

],
"license": "MIT",
"lint-staged": {
"src/*.ts": [
"eslint --cache --fix",
"prettier --ignore-unknown --write"
],
"*.md": [
"prettier --ignore-unknown --write"
]
},
"scripts": {
"check:format": "prettier --check \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
"fix:format": "prettier --write \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
"check:lint": "eslint --ext .ts ./src",
"fix:lint": "eslint --fix --ext .ts ./src",
"check": "yarn check:lint && yarn check:format",
"fix": "yarn fix:lint && yarn fix:format",
"prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts *.md --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts *.md --ignore-unknown --no-error-on-unmatched-pattern",
"lint:check": "eslint --cache --ext .ts ./src",
"lint:fix": "eslint --cache --fix --ext .ts ./src",
"check": "yarn lint:check && yarn prettier:check",
"fix": "yarn lint:fix && yarn prettier:fix",
"clean": "rm -rf lib/* deno/lib/*",
"build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno",
"build:deno": "node ./deno/build.mjs",
"build:esm": "rollup --config rollup.config.js",
"build:cjs": "tsc --p tsconfig.cjs.json",
"build:types": "tsc --p tsconfig.types.json",
"rollup": "rollup --config rollup.config.js",
"test": "node --trace-warnings node_modules/.bin/jest --coverage && yarn run badge",
"testone": "jest",
"badge": "make-coverage-badge --output-path ./coverage.svg",
"build:deno": "node ./deno-build.mjs && cp ./README.md ./deno/lib",
"build:esm": "rollup --config ./configs/rollup.config.js",
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json",
"build:types": "tsc -p ./configs/tsconfig.types.json",
"build:test": "tsc -p ./configs/tsconfig.test.json",
"test:watch": "yarn test:ts-jest --watch",
"test": "yarn test:ts-jest",
"test:babel": "jest --coverage --config ./configs/babel-jest.config.json",
"test:bun": "bun test",
"test:vitest": "npx vitest --config ./configs/vitest.config.ts",
"test:ts-jest": "npx jest --config ./configs/ts-jest.config.json",
"test:swc": "npx jest --config ./configs/swc-jest.config.json",
"test:deno": "cd deno && deno test",
"prepublishOnly": "npm run test && npm run build && npm run build:deno",
"play": "nodemon -e ts -w . -x ts-node src/playground.ts --project tsconfig.json --trace-warnings",
"play": "nodemon -e ts -w . -x tsx playground.ts",
"depcruise": "depcruise -c .dependency-cruiser.js src",
"benchmark": "ts-node src/benchmarks/index.ts"
"benchmark": "tsx src/benchmarks/index.ts",
"prepare": "husky install"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.0",
"@types/benchmark": "^2.1.0",
"@types/jest": "^26.0.17",
"@types/node": "^14.14.10",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"benchmark": "^2.1.4",
"dependency-cruiser": "^9.19.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^1.1.0",
"husky": "^4.3.4",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"make-coverage-badge": "^1.2.0",
"nodemon": "^2.0.2",
"prettier": "^2.2.1",
"rollup": "^2.42.1",
"rollup-plugin-uglify": "^6.0.4",
"ts-jest": "^26.4.4",
"ts-node": "^9.1.0",
"tslib": "^2.3.1",
"typescript": "^4.4.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && yarn build:deno && git add .",
"pre-push": "lint-staged && yarn build && yarn test"
"sideEffects": false,
"support": {
"backing": {
"npm-funding": true
}
},
"lint-staged": {
"*.ts": [
"yarn fix:lint",
"yarn fix:format"
]
},
"types": "./index.d.ts",
"dependencies": {}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc