New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zod

Package Overview
Dependencies
Maintainers
2
Versions
374
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod - npm Package Compare versions

Comparing version 2.0.0-beta.29 to 2.0.0-beta.30

lib/cjs/ZodDef.d.ts

6

lib/cjs/codegen.d.ts

@@ -1,2 +0,2 @@

import { ZodType } from './types/base';
import { ZodType } from ".";
declare type TypeResult = {

@@ -11,9 +11,9 @@ schema: any;

randomId: () => string;
findBySchema: (schema: ZodType<any, any, any>) => TypeResult | undefined;
findBySchema: (schema: ZodType<any, any>) => TypeResult | undefined;
findById: (id: string) => TypeResult;
dump: () => string;
setType: (id: string, type: string) => TypeResult;
generate: (schema: ZodType<any, any, any>) => TypeResult;
generate: (schema: ZodType<any, any>) => TypeResult;
static create: () => ZodCodeGenerator;
}
export {};

@@ -14,4 +14,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ZodCodeGenerator = void 0;
var util_1 = require("./helpers/util");
var base_1 = require("./types/base");
var _1 = require(".");
var isOptional = function (schema) {

@@ -40,3 +41,3 @@ return schema.isOptional();

.map(function (item) { return "type " + item.id + " = Identity<" + item.type + ">;"; })
.join('\n\n') + "\n";
.join("\n\n") + "\n";
};

@@ -62,31 +63,31 @@ this.setType = function (id, type) {

switch (def.t) {
case base_1.ZodTypes.string:
case _1.ZodTypes.string:
return _this.setType(id, "string");
case base_1.ZodTypes.number:
case _1.ZodTypes.number:
return _this.setType(id, "number");
case base_1.ZodTypes.bigint:
case _1.ZodTypes.bigint:
return _this.setType(id, "bigint");
case base_1.ZodTypes.boolean:
case _1.ZodTypes.boolean:
return _this.setType(id, "boolean");
case base_1.ZodTypes.date:
case _1.ZodTypes.date:
return _this.setType(id, "Date");
case base_1.ZodTypes.undefined:
case _1.ZodTypes.undefined:
return _this.setType(id, "undefined");
case base_1.ZodTypes.null:
case _1.ZodTypes.null:
return _this.setType(id, "null");
case base_1.ZodTypes.any:
case _1.ZodTypes.any:
return _this.setType(id, "any");
case base_1.ZodTypes.unknown:
case _1.ZodTypes.unknown:
return _this.setType(id, "unknown");
case base_1.ZodTypes.never:
case _1.ZodTypes.never:
return _this.setType(id, "never");
case base_1.ZodTypes.void:
case _1.ZodTypes.void:
return _this.setType(id, "void");
case base_1.ZodTypes.literal:
case _1.ZodTypes.literal:
var val = def.value;
var literalType = typeof val === 'string' ? "\"" + val + "\"" : "" + val;
var literalType = typeof val === "string" ? "\"" + val + "\"" : "" + val;
return _this.setType(id, literalType);
case base_1.ZodTypes.enum:
return _this.setType(id, def.values.map(function (v) { return "\"" + v + "\""; }).join(' | '));
case base_1.ZodTypes.object:
case _1.ZodTypes.enum:
return _this.setType(id, def.values.map(function (v) { return "\"" + v + "\""; }).join(" | "));
case _1.ZodTypes.object:
var objectLines = [];

@@ -97,3 +98,3 @@ var shape = def.shape();

var childType = _this.generate(childSchema);
var OPTKEY = isOptional(childSchema) ? '?' : '';
var OPTKEY = isOptional(childSchema) ? "?" : "";
objectLines.push("" + key + OPTKEY + ": " + childType.id);

@@ -103,6 +104,6 @@ }

.map(function (line) { return " " + line + ";"; })
.join('\n') + "\n}";
.join("\n") + "\n}";
_this.setType(id, "" + baseStruct);
break;
case base_1.ZodTypes.tuple:
case _1.ZodTypes.tuple:
var tupleLines = [];

@@ -125,14 +126,14 @@ try {

.map(function (line) { return " " + line + ","; })
.join('\n') + "\n]";
.join("\n") + "\n]";
return _this.setType(id, "" + baseTuple);
case base_1.ZodTypes.array:
case _1.ZodTypes.array:
return _this.setType(id, _this.generate(def.type).id + "[]");
case base_1.ZodTypes.function:
case _1.ZodTypes.function:
var args = _this.generate(def.args);
var returns = _this.generate(def.returns);
return _this.setType(id, "(...args: " + args.id + ")=>" + returns.id);
case base_1.ZodTypes.promise:
case _1.ZodTypes.promise:
var promValue = _this.generate(def.type);
return _this.setType(id, "Promise<" + promValue.id + ">");
case base_1.ZodTypes.union:
case _1.ZodTypes.union:
var unionLines = [];

@@ -154,18 +155,18 @@ try {

return _this.setType(id, unionLines.join(" | "));
case base_1.ZodTypes.intersection:
case _1.ZodTypes.intersection:
return _this.setType(id, _this.generate(def.left).id + " & " + _this.generate(def.right).id);
case base_1.ZodTypes.record:
case _1.ZodTypes.record:
return _this.setType(id, "{[k:string]: " + _this.generate(def.valueType).id + "}");
case base_1.ZodTypes.transformer:
case _1.ZodTypes.transformer:
return _this.setType(id, _this.generate(def.output).id);
case base_1.ZodTypes.map:
case _1.ZodTypes.map:
return _this.setType(id, "Map<" + _this.generate(def.keyType).id + ", " + _this.generate(def.valueType).id + ">");
case base_1.ZodTypes.lazy:
case _1.ZodTypes.lazy:
var lazyType = def.getter();
return _this.setType(id, _this.generate(lazyType).id);
case base_1.ZodTypes.nativeEnum:
return _this.setType(id, 'asdf');
case base_1.ZodTypes.optional:
case _1.ZodTypes.nativeEnum:
return _this.setType(id, "asdf");
case _1.ZodTypes.optional:
return _this.setType(id, _this.generate(def.innerType).id + " | undefined");
case base_1.ZodTypes.nullable:
case _1.ZodTypes.nullable:
return _this.setType(id, _this.generate(def.innerType).id + " | null");

@@ -172,0 +173,0 @@ default:

@@ -1,2 +0,2 @@

import * as z from './index';
import * as z from "./index";
export declare const crazySchema: z.ZodObject<{

@@ -3,0 +3,0 @@ tuple: z.ZodTuple<[z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodOptional<z.ZodNullable<z.ZodBoolean>>, z.ZodOptional<z.ZodNullable<z.ZodNull>>, z.ZodOptional<z.ZodNullable<z.ZodUndefined>>, z.ZodOptional<z.ZodNullable<z.ZodLiteral<"1234">>>]>;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -38,37 +57,13 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.asyncCrazySchema = exports.crazySchema = void 0;
var z = __importStar(require("./index"));
exports.crazySchema = z.object({
tuple: z.tuple([
z
.string()
.nullable()
.optional(),
z
.number()
.nullable()
.optional(),
z
.boolean()
.nullable()
.optional(),
z
.null()
.nullable()
.optional(),
z
.undefined()
.nullable()
.optional(),
z
.literal('1234')
.nullable()
.optional(),
z.string().nullable().optional(),
z.number().nullable().optional(),
z.boolean().nullable().optional(),
z.null().nullable().optional(),
z.undefined().nullable().optional(),
z.literal("1234").nullable().optional(),
]),

@@ -80,3 +75,3 @@ merged: z

.merge(z.object({ k1: z.string().nullable(), k2: z.number() })),
union: z.array(z.union([z.literal('asdf'), z.literal(12)])).nonempty(),
union: z.array(z.union([z.literal("asdf"), z.literal(12)])).nonempty(),
array: z.array(z.number()),

@@ -88,3 +83,3 @@ sumTransformer: z.transformer(z.array(z.number()), z.number(), function (arg) {

intersection: z.intersection(z.object({ p1: z.string().optional() }), z.object({ p1: z.number().optional() })),
enum: z.intersection(z.enum(['zero', 'one']), z.enum(['one', 'two'])),
enum: z.intersection(z.enum(["zero", "one"]), z.enum(["one", "two"])),
nonstrict: z.object({ points: z.number() }).nonstrict(),

@@ -91,0 +86,0 @@ numProm: z.promise(z.number()),

@@ -1,2 +0,2 @@

import { ZodIssueOptionalMessage } from './ZodError';
import { ZodIssueOptionalMessage } from "./ZodError";
declare type ErrorMapCtx = {

@@ -3,0 +3,0 @@ defaultError: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultErrorMap = void 0;
var util_1 = require("./helpers/util");
var ZodError_1 = require("./ZodError");
var util_1 = require("./helpers/util");
exports.defaultErrorMap = function (error, _ctx) {
var defaultErrorMap = function (error, _ctx) {
var message;
switch (error.code) {
case ZodError_1.ZodIssueCode.invalid_type:
if (error.received === 'undefined') {
message = 'Required';
if (error.received === "undefined") {
message = "Required";
}

@@ -22,3 +23,3 @@ else {

.map(function (k) { return "'" + k + "'"; })
.join(', ');
.join(", ");
break;

@@ -32,3 +33,3 @@ case ZodError_1.ZodIssueCode.invalid_union:

case ZodError_1.ZodIssueCode.invalid_enum_value:
message = "Input must be one of these values: " + error.options.join(', ');
message = "Input must be one of these values: " + error.options.join(", ");
break;

@@ -45,26 +46,26 @@ case ZodError_1.ZodIssueCode.invalid_arguments:

case ZodError_1.ZodIssueCode.invalid_string:
if (error.validation !== 'regex')
if (error.validation !== "regex")
message = "Invalid " + error.validation;
else
message = 'Invalid';
message = "Invalid";
break;
case ZodError_1.ZodIssueCode.too_small:
if (error.type === 'array')
if (error.type === "array")
message = "Should have " + (error.inclusive ? "at least" : "more than") + " " + error.minimum + " items";
else if (error.type === 'string')
else if (error.type === "string")
message = "Should be " + (error.inclusive ? "at least" : "over") + " " + error.minimum + " characters";
else if (error.type === 'number')
else if (error.type === "number")
message = "Value should be greater than " + (error.inclusive ? "or equal to " : "") + error.minimum;
else
message = 'Invalid input';
message = "Invalid input";
break;
case ZodError_1.ZodIssueCode.too_big:
if (error.type === 'array')
if (error.type === "array")
message = "Should have " + (error.inclusive ? "at most" : "less than") + " " + error.maximum + " items";
else if (error.type === 'string')
else if (error.type === "string")
message = "Should be " + (error.inclusive ? "at most" : "under") + " " + error.maximum + " characters long";
else if (error.type === 'number')
else if (error.type === "number")
message = "Value should be less than " + (error.inclusive ? "or equal to " : "") + error.maximum;
else
message = 'Invalid input';
message = "Invalid input";
break;

@@ -83,2 +84,3 @@ case ZodError_1.ZodIssueCode.custom:

};
exports.defaultErrorMap = defaultErrorMap;
//# sourceMappingURL=defaultErrorMap.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorUtil = void 0;
var errorUtil;
(function (errorUtil) {
errorUtil.errToObj = function (message) { return (typeof message === 'string' ? { message: message } : message || {}); };
errorUtil.errToObj = function (message) {
return typeof message === "string" ? { message: message } : message || {};
};
})(errorUtil = exports.errorUtil || (exports.errorUtil = {}));
//# sourceMappingURL=errorUtil.js.map

@@ -1,2 +0,2 @@

import { Primitive } from './primitive';
import { Primitive } from "./primitive";
declare type AnyObject = {

@@ -24,4 +24,4 @@ [k: string]: any;

never: never;
}[T extends null | undefined | Primitive | Array<Primitive> ? 'never' : any extends T ? 'never' : T extends Array<AnyObject> ? 'array' : IsObject<T> extends true ? 'object' : 'rest'];
type PickTest<T, P extends any> = P extends true ? 'true' : true extends IsObject<T> ? 'object' : true extends IsObjectArray<T> ? 'array' : 'rest';
}[T extends null | undefined | Primitive | Array<Primitive> ? "never" : any extends T ? "never" : T extends Array<AnyObject> ? "array" : IsObject<T> extends true ? "object" : "rest"];
type PickTest<T, P extends any> = P extends true ? "true" : true extends IsObject<T> ? "object" : true extends IsObjectArray<T> ? "array" : "rest";
type Pick<T, P> = null extends T ? undefined extends T ? BasePick<NonNullable<T>, P> | null | undefined : BasePick<NonNullable<T>, P> | null : undefined extends T ? BasePick<NonNullable<T>, P> | undefined : BasePick<NonNullable<T>, P>;

@@ -38,4 +38,4 @@ type BasePick<T, P extends any> = {

any: any;
}[IsAny<T> extends true ? 'any' : IsNever<T> extends true ? 'never' : IsNever<P> extends true ? 'true' : IsTrue<P> extends true ? 'true' : true extends IsObject<T> ? 'object' : true extends IsObjectArray<T> ? 'array' : 'any'];
}[IsAny<T> extends true ? "any" : IsNever<T> extends true ? "never" : IsNever<P> extends true ? "true" : IsTrue<P> extends true ? "true" : true extends IsObject<T> ? "object" : true extends IsObjectArray<T> ? "array" : "any"];
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mocker = void 0;
function getRandomInt(max) {

@@ -18,7 +19,5 @@ return Math.floor(Math.random() * Math.floor(max));

get: function () {
return Math.random()
.toString(36)
.substring(7);
return Math.random().toString(36).substring(7);
},
enumerable: true,
enumerable: false,
configurable: true

@@ -30,3 +29,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -38,3 +37,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -46,3 +45,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -54,3 +53,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -62,3 +61,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -70,3 +69,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -78,3 +77,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -86,3 +85,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -94,3 +93,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -102,3 +101,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -110,3 +109,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -118,3 +117,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -121,0 +120,0 @@ });

@@ -1,3 +0,2 @@

import { ZodRawShape } from '../types/base';
import { ZodObject, AnyZodObject } from '../types/object';
import { ZodRawShape } from "..";
export declare namespace objectUtil {

@@ -27,4 +26,3 @@ export type MergeShapes<U extends ZodRawShape, V extends ZodRawShape> = {

export const mergeShapes: <U extends ZodRawShape, T extends ZodRawShape>(first: U, second: T) => T & U;
export const mergeObjects: <First extends AnyZodObject>(first: First) => <Second extends AnyZodObject>(second: Second) => ZodObject<First["_shape"] & Second["_shape"], First["_unknownKeys"], First["_catchall"], import("../types/object").objectOutputType<First["_shape"] & Second["_shape"], First["_catchall"]>, import("../types/object").objectInputType<First["_shape"] & Second["_shape"], First["_catchall"]>>;
export {};
}

@@ -24,26 +24,5 @@ "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 __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var base_1 = require("../types/base");
var intersection_1 = require("../types/intersection");
var object_1 = require("../types/object");
exports.objectUtil = void 0;
var __1 = require("..");
var objectUtil;

@@ -60,3 +39,3 @@ (function (objectUtil) {

var k = sharedKeys_1_1.value;
sharedShape[k] = intersection_1.ZodIntersection.create(first[k], second[k]);
sharedShape[k] = __1.ZodIntersection.create(first[k], second[k]);
}

@@ -73,14 +52,3 @@ }

};
objectUtil.mergeObjects = function (first) { return function (second) {
var mergedShape = objectUtil.mergeShapes(first._def.shape(), second._def.shape());
var merged = new object_1.ZodObject({
t: base_1.ZodTypes.object,
checks: __spread((first._def.checks || []), (second._def.checks || [])),
unknownKeys: first._def.unknownKeys,
catchall: first._def.catchall,
shape: function () { return mergedShape; },
});
return merged;
}; };
})(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
//# sourceMappingURL=objectUtil.js.map

@@ -1,16 +0,17 @@

import * as z from '../index';
import { AnyZodObject } from '../types/object';
import { ZodTypeAny, ZodObject, ZodOptional } from "..";
declare type AnyZodObject = ZodObject<any, any, any>;
export declare namespace partialUtil {
type RootDeepPartial<T extends z.ZodTypeAny> = {
object: T extends AnyZodObject ? z.ZodObject<{
[k in keyof T['_shape']]: DeepPartial<T['_shape'][k]>;
}, T['_unknownKeys'], T['_catchall']> : never;
rest: ReturnType<T['optional']>;
}[T extends AnyZodObject ? 'object' : 'rest'];
type DeepPartial<T extends z.ZodTypeAny> = {
object: T extends z.ZodObject<infer Shape, infer Params, infer Catchall> ? z.ZodOptional<z.ZodObject<{
type RootDeepPartial<T extends ZodTypeAny> = {
object: T extends AnyZodObject ? ZodObject<{
[k in keyof T["_shape"]]: DeepPartial<T["_shape"][k]>;
}, T["_unknownKeys"], T["_catchall"]> : never;
rest: ReturnType<T["optional"]>;
}[T extends AnyZodObject ? "object" : "rest"];
type DeepPartial<T extends ZodTypeAny> = {
object: T extends ZodObject<infer Shape, infer Params, infer Catchall> ? ZodOptional<ZodObject<{
[k in keyof Shape]: DeepPartial<Shape[k]>;
}, Params, Catchall>> : never;
rest: ReturnType<T['optional']>;
}[T extends z.ZodObject<any> ? 'object' : 'rest'];
rest: ReturnType<T["optional"]>;
}[T extends ZodObject<any> ? "object" : "rest"];
}
export {};

@@ -14,3 +14,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.INVALID = Symbol('invalid_data');
exports.util = exports.INVALID = void 0;
exports.INVALID = Symbol("invalid_data");
var util;

@@ -42,3 +43,3 @@ (function (util) {

var e_2, _a;
var validKeys = Object.keys(obj).filter(function (k) { return typeof obj[obj[k]] !== 'number'; });
var validKeys = Object.keys(obj).filter(function (k) { return typeof obj[obj[k]] !== "number"; });
var filtered = {};

@@ -45,0 +46,0 @@ try {

@@ -1,33 +0,33 @@

import { ZodString, ZodStringDef } from './types/string';
import { ZodNumber, ZodNumberDef } from './types/number';
import { ZodBigInt, ZodBigIntDef } from './types/bigint';
import { ZodBoolean, ZodBooleanDef } from './types/boolean';
import { ZodDate, ZodDateDef } from './types/date';
import { ZodUndefined, ZodUndefinedDef } from './types/undefined';
import { ZodNull, ZodNullDef } from './types/null';
import { ZodAny, ZodAnyDef } from './types/any';
import { ZodUnknown, ZodUnknownDef } from './types/unknown';
import { ZodNever, ZodNeverDef } from './types/never';
import { ZodVoid, ZodVoidDef } from './types/void';
import { ZodArray, ZodArrayDef } from './types/array';
import { ZodObject, ZodObjectDef } from './types/object';
import { ZodUnion, ZodUnionDef } from './types/union';
import { ZodIntersection, ZodIntersectionDef } from './types/intersection';
import { ZodTuple, ZodTupleDef } from './types/tuple';
import { ZodRecord, ZodRecordDef } from './types/record';
import { ZodMap, ZodMapDef } from './types/map';
import { ZodFunction, ZodFunctionDef } from './types/function';
import { ZodLazy, ZodLazyDef } from './types/lazy';
import { ZodLiteral, ZodLiteralDef } from './types/literal';
import { ZodEnum, ZodEnumDef } from './types/enum';
import { ZodNativeEnum, ZodNativeEnumDef } from './types/nativeEnum';
import { ZodPromise, ZodPromiseDef } from './types/promise';
import { ZodTransformer, ZodTransformerDef } from './types/transformer';
import { ZodOptional, ZodOptionalDef } from './types/optional';
import { ZodNullable, ZodNullableDef } from './types/nullable';
import { TypeOf, input, output, ZodType, ZodTypeAny, ZodTypeDef, ZodTypes } from './types/base';
import { ZodParsedType } from './parser';
import { ZodErrorMap } from './defaultErrorMap';
import { ZodCodeGenerator } from './codegen';
export { ZodTypeDef, ZodTypes };
import { ZodType, ZodTypeDef, ZodTypeAny, ZodRawShape, input, output, TypeOf, RefinementCtx } from "./types/base";
import { ZodErrorMap } from "./defaultErrorMap";
import { ZodAny } from "./types/any";
import { ZodArray } from "./types/array";
import { ZodBigInt } from "./types/bigint";
import { ZodBoolean } from "./types/boolean";
import { ZodDate } from "./types/date";
import { ZodEnum } from "./types/enum";
import { ZodFunction } from "./types/function";
import { ZodIntersection } from "./types/intersection";
import { ZodLazy } from "./types/lazy";
import { ZodLiteral } from "./types/literal";
import { ZodMap } from "./types/map";
import { ZodNativeEnum } from "./types/nativeEnum";
import { ZodNever } from "./types/never";
import { ZodNull } from "./types/null";
import { ZodNullable, ZodNullableType } from "./types/nullable";
import { ZodNumber } from "./types/number";
import { ZodObject } from "./types/object";
import { ZodOptional, ZodOptionalType } from "./types/optional";
import { ZodPromise } from "./types/promise";
import { ZodRecord } from "./types/record";
import { ZodString } from "./types/string";
import { ZodTransformer } from "./types/transformer";
import { ZodTuple } from "./types/tuple";
import { ZodUndefined } from "./types/undefined";
import { ZodUnion } from "./types/union";
import { ZodUnknown } from "./types/unknown";
import { ZodVoid } from "./types/void";
import { ZodParsedType } from "./ZodParsedType";
import { ZodTypes } from "./ZodTypes";
import { ZodCodeGenerator } from "./codegen";
declare const stringType: () => ZodString;

@@ -45,6 +45,6 @@ declare const numberType: () => ZodNumber;

declare const arrayType: <T extends ZodTypeAny>(schema: T) => ZodArray<T>;
declare const objectType: <T extends import("./types/base").ZodRawShape>(shape: T) => ZodObject<T, "passthrough", ZodTypeAny, { [k_1 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
declare const objectType: <T extends ZodRawShape>(shape: T) => ZodObject<T, "passthrough", ZodTypeAny, { [k_1 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
declare const unionType: <T extends [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T) => ZodUnion<T>;
declare const intersectionType: <T extends ZodTypeAny, U extends ZodTypeAny>(left: T, right: U) => ZodIntersection<T, U>;
declare const tupleType: <T extends [] | [ZodTypeAny, ...ZodTypeAny[]]>(schemas: T) => ZodTuple<T>;
declare const tupleType: <T extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: T) => ZodTuple<T>;
declare const recordType: <Value extends ZodTypeAny = ZodTypeAny>(valueType: Value) => ZodRecord<Value>;

@@ -54,3 +54,3 @@ declare const mapType: <Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny>(keyType: Key, valueType: Value) => ZodMap<Key, Value>;

declare const lazyType: <T extends ZodTypeAny>(getter: () => T) => ZodLazy<T>;
declare const literalType: <T extends import("./helpers/primitive").Primitive>(value: T) => ZodLiteral<T>;
declare const literalType: <T extends string | number | bigint | boolean | null | undefined>(value: T) => ZodLiteral<T>;
declare const enumType: <U extends string, T extends [U, ...U[]]>(values: T) => ZodEnum<T>;

@@ -63,4 +63,4 @@ declare const nativeEnumType: <T extends {

declare const transformerType: <I extends ZodTypeAny, O extends ZodTypeAny>(input: I, output: O, transformer: (arg: I["_output"]) => O["_input"] | Promise<O["_input"]>) => ZodTransformer<I, O>;
declare const optionalType: <T extends ZodTypeAny>(type: T) => import("./types/optional").ZodOptionalType<T>;
declare const nullableType: <T extends ZodTypeAny>(type: T) => import("./types/nullable").ZodNullableType<T>;
declare const optionalType: <T extends ZodTypeAny>(type: T) => ZodOptionalType<T>;
declare const nullableType: <T extends ZodTypeAny>(type: T) => ZodNullableType<T>;
declare const ostring: () => ZodOptional<ZodString>;

@@ -70,11 +70,9 @@ declare const onumber: () => ZodOptional<ZodNumber>;

declare const codegen: () => ZodCodeGenerator;
export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: string | Partial<Pick<import("./ZodError").ZodCustomIssue, "path" | "message" | "params">> | ((arg: any) => Partial<Pick<import("./ZodError").ZodCustomIssue, "path" | "message" | "params">>) | undefined) => ZodType<T, ZodTypeDef, T>;
declare const instanceOfType: <T extends new (...args: any[]) => any>(cls: T, params?: string | Partial<Pick<import("./ZodError").ZodCustomIssue, "path" | "message" | "params">> | ((arg: any) => Partial<Pick<import("./ZodError").ZodCustomIssue, "path" | "message" | "params">>) | undefined) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
export { stringType as string, numberType as number, bigIntType as bigint, booleanType as boolean, dateType as date, undefinedType as undefined, nullType as null, anyType as any, unknownType as unknown, neverType as never, voidType as void, arrayType as array, objectType as object, unionType as union, intersectionType as intersection, tupleType as tuple, recordType as record, mapType as map, functionType as function, lazyType as lazy, literalType as literal, enumType as enum, nativeEnumType as nativeEnum, promiseType as promise, instanceOfType as instanceof, transformerType as transformer, optionalType as optional, nullableType as nullable, ostring, onumber, oboolean, codegen, };
export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<T, ZodTypeDef, T>;
declare const instanceOfType: <T extends new (...args: any[]) => any>(cls: T, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
export { ZodType, ZodType as Schema, ZodType as ZodSchema, ZodTypeDef, ZodRawShape, RefinementCtx, ZodTypes, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodCodeGenerator, ZodDate, ZodEnum, ZodErrorMap, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNullableType, ZodNumber, ZodObject, ZodOptional, ZodOptionalType, ZodParsedType, ZodPromise, ZodRecord, ZodString, ZodTransformer, ZodTuple, ZodTypeAny, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, TypeOf as infer, input, output, TypeOf, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, codegen, dateType as date, 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, promiseType as promise, recordType as record, stringType as string, transformerType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, };
export declare const late: {
object: <T extends import("./types/base").ZodRawShape>(shape: () => T) => ZodObject<T, "passthrough", ZodTypeAny, { [k_1 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
object: <T extends ZodRawShape>(shape: () => T) => ZodObject<T, "passthrough", ZodTypeAny, { [k_1 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: import("./helpers/objectUtil").objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
};
export { ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, ZodIntersection, ZodTuple, ZodRecord, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodTransformer, ZodOptional, ZodNullable, ZodType, ZodType as Schema, ZodType as ZodSchema, ZodTypeAny, ZodErrorMap, ZodParsedType, ZodCodeGenerator, };
export { TypeOf, TypeOf as infer, input, output };
export * from './ZodError';
export declare type ZodDef = ZodStringDef | ZodNumberDef | ZodBigIntDef | ZodBooleanDef | ZodDateDef | ZodUndefinedDef | ZodNullDef | ZodAnyDef | ZodUnknownDef | ZodNeverDef | ZodVoidDef | ZodArrayDef | ZodObjectDef | ZodUnionDef | ZodIntersectionDef | ZodTupleDef | ZodRecordDef | ZodMapDef | ZodFunctionDef | ZodLazyDef | ZodLiteralDef | ZodEnumDef | ZodTransformerDef | ZodNativeEnumDef | ZodOptionalDef | ZodNullableDef | ZodPromiseDef;
export * from "./ZodDef";
export * from "./ZodError";
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
var string_1 = require("./types/string");
exports.ZodString = string_1.ZodString;
var number_1 = require("./types/number");
exports.ZodNumber = number_1.ZodNumber;
exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.date = exports.codegen = exports.boolean = exports.bigint = exports.array = exports.any = exports.ZodVoid = exports.ZodUnknown = exports.ZodUnion = exports.ZodUndefined = exports.ZodTuple = exports.ZodTransformer = exports.ZodString = exports.ZodRecord = exports.ZodPromise = exports.ZodParsedType = exports.ZodOptional = exports.ZodObject = exports.ZodNumber = exports.ZodNullable = exports.ZodNull = exports.ZodNever = exports.ZodNativeEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodIntersection = exports.ZodFunction = exports.ZodEnum = exports.ZodDate = exports.ZodCodeGenerator = exports.ZodBoolean = exports.ZodBigInt = exports.ZodArray = exports.ZodAny = exports.ZodTypes = exports.ZodSchema = exports.Schema = exports.ZodType = exports.custom = void 0;
exports.late = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.string = exports.record = exports.promise = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = void 0;
var base_1 = require("./types/base");
Object.defineProperty(exports, "ZodType", { enumerable: true, get: function () { return base_1.ZodType; } });
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return base_1.ZodType; } });
Object.defineProperty(exports, "ZodSchema", { enumerable: true, get: function () { return base_1.ZodType; } });
var any_1 = require("./types/any");
Object.defineProperty(exports, "ZodAny", { enumerable: true, get: function () { return any_1.ZodAny; } });
var array_1 = require("./types/array");
Object.defineProperty(exports, "ZodArray", { enumerable: true, get: function () { return array_1.ZodArray; } });
var bigint_1 = require("./types/bigint");
exports.ZodBigInt = bigint_1.ZodBigInt;
Object.defineProperty(exports, "ZodBigInt", { enumerable: true, get: function () { return bigint_1.ZodBigInt; } });
var boolean_1 = require("./types/boolean");
exports.ZodBoolean = boolean_1.ZodBoolean;
Object.defineProperty(exports, "ZodBoolean", { enumerable: true, get: function () { return boolean_1.ZodBoolean; } });
var date_1 = require("./types/date");
exports.ZodDate = date_1.ZodDate;
var undefined_1 = require("./types/undefined");
exports.ZodUndefined = undefined_1.ZodUndefined;
var null_1 = require("./types/null");
exports.ZodNull = null_1.ZodNull;
var any_1 = require("./types/any");
exports.ZodAny = any_1.ZodAny;
var unknown_1 = require("./types/unknown");
exports.ZodUnknown = unknown_1.ZodUnknown;
var never_1 = require("./types/never");
exports.ZodNever = never_1.ZodNever;
var void_1 = require("./types/void");
exports.ZodVoid = void_1.ZodVoid;
var array_1 = require("./types/array");
exports.ZodArray = array_1.ZodArray;
var object_1 = require("./types/object");
exports.ZodObject = object_1.ZodObject;
var union_1 = require("./types/union");
exports.ZodUnion = union_1.ZodUnion;
Object.defineProperty(exports, "ZodDate", { enumerable: true, get: function () { return date_1.ZodDate; } });
var enum_1 = require("./types/enum");
Object.defineProperty(exports, "ZodEnum", { enumerable: true, get: function () { return enum_1.ZodEnum; } });
var function_1 = require("./types/function");
Object.defineProperty(exports, "ZodFunction", { enumerable: true, get: function () { return function_1.ZodFunction; } });
var intersection_1 = require("./types/intersection");
exports.ZodIntersection = intersection_1.ZodIntersection;
var tuple_1 = require("./types/tuple");
exports.ZodTuple = tuple_1.ZodTuple;
var record_1 = require("./types/record");
exports.ZodRecord = record_1.ZodRecord;
var map_1 = require("./types/map");
var function_1 = require("./types/function");
exports.ZodFunction = function_1.ZodFunction;
Object.defineProperty(exports, "ZodIntersection", { enumerable: true, get: function () { return intersection_1.ZodIntersection; } });
var lazy_1 = require("./types/lazy");
exports.ZodLazy = lazy_1.ZodLazy;
Object.defineProperty(exports, "ZodLazy", { enumerable: true, get: function () { return lazy_1.ZodLazy; } });
var literal_1 = require("./types/literal");
exports.ZodLiteral = literal_1.ZodLiteral;
var enum_1 = require("./types/enum");
exports.ZodEnum = enum_1.ZodEnum;
Object.defineProperty(exports, "ZodLiteral", { enumerable: true, get: function () { return literal_1.ZodLiteral; } });
var map_1 = require("./types/map");
var nativeEnum_1 = require("./types/nativeEnum");
exports.ZodNativeEnum = nativeEnum_1.ZodNativeEnum;
Object.defineProperty(exports, "ZodNativeEnum", { enumerable: true, get: function () { return nativeEnum_1.ZodNativeEnum; } });
var never_1 = require("./types/never");
Object.defineProperty(exports, "ZodNever", { enumerable: true, get: function () { return never_1.ZodNever; } });
var null_1 = require("./types/null");
Object.defineProperty(exports, "ZodNull", { enumerable: true, get: function () { return null_1.ZodNull; } });
var nullable_1 = require("./types/nullable");
Object.defineProperty(exports, "ZodNullable", { enumerable: true, get: function () { return nullable_1.ZodNullable; } });
var number_1 = require("./types/number");
Object.defineProperty(exports, "ZodNumber", { enumerable: true, get: function () { return number_1.ZodNumber; } });
var object_1 = require("./types/object");
Object.defineProperty(exports, "ZodObject", { enumerable: true, get: function () { return object_1.ZodObject; } });
var optional_1 = require("./types/optional");
Object.defineProperty(exports, "ZodOptional", { enumerable: true, get: function () { return optional_1.ZodOptional; } });
var promise_1 = require("./types/promise");
exports.ZodPromise = promise_1.ZodPromise;
Object.defineProperty(exports, "ZodPromise", { enumerable: true, get: function () { return promise_1.ZodPromise; } });
var record_1 = require("./types/record");
Object.defineProperty(exports, "ZodRecord", { enumerable: true, get: function () { return record_1.ZodRecord; } });
var string_1 = require("./types/string");
Object.defineProperty(exports, "ZodString", { enumerable: true, get: function () { return string_1.ZodString; } });
var transformer_1 = require("./types/transformer");
exports.ZodTransformer = transformer_1.ZodTransformer;
var optional_1 = require("./types/optional");
exports.ZodOptional = optional_1.ZodOptional;
var nullable_1 = require("./types/nullable");
exports.ZodNullable = nullable_1.ZodNullable;
var base_1 = require("./types/base");
exports.ZodType = base_1.ZodType;
exports.Schema = base_1.ZodType;
exports.ZodSchema = base_1.ZodType;
exports.ZodTypes = base_1.ZodTypes;
var parser_1 = require("./parser");
exports.ZodParsedType = parser_1.ZodParsedType;
Object.defineProperty(exports, "ZodTransformer", { enumerable: true, get: function () { return transformer_1.ZodTransformer; } });
var tuple_1 = require("./types/tuple");
Object.defineProperty(exports, "ZodTuple", { enumerable: true, get: function () { return tuple_1.ZodTuple; } });
var undefined_1 = require("./types/undefined");
Object.defineProperty(exports, "ZodUndefined", { enumerable: true, get: function () { return undefined_1.ZodUndefined; } });
var union_1 = require("./types/union");
Object.defineProperty(exports, "ZodUnion", { enumerable: true, get: function () { return union_1.ZodUnion; } });
var unknown_1 = require("./types/unknown");
Object.defineProperty(exports, "ZodUnknown", { enumerable: true, get: function () { return unknown_1.ZodUnknown; } });
var void_1 = require("./types/void");
Object.defineProperty(exports, "ZodVoid", { enumerable: true, get: function () { return void_1.ZodVoid; } });
var ZodParsedType_1 = require("./ZodParsedType");
Object.defineProperty(exports, "ZodParsedType", { enumerable: true, get: function () { return ZodParsedType_1.ZodParsedType; } });
var ZodTypes_1 = require("./ZodTypes");
Object.defineProperty(exports, "ZodTypes", { enumerable: true, get: function () { return ZodTypes_1.ZodTypes; } });
var codegen_1 = require("./codegen");
exports.ZodCodeGenerator = codegen_1.ZodCodeGenerator;
Object.defineProperty(exports, "ZodCodeGenerator", { enumerable: true, get: function () { return codegen_1.ZodCodeGenerator; } });
var stringType = string_1.ZodString.create;

@@ -130,3 +140,3 @@ exports.string = stringType;

exports.codegen = codegen;
exports.custom = function (check, params) {
var custom = function (check, params) {
if (check)

@@ -136,2 +146,3 @@ return anyType().refine(check, params);

};
exports.custom = custom;
var instanceOfType = function (cls, params) {

@@ -147,3 +158,4 @@ if (params === void 0) { params = {

};
__export(require("./ZodError"));
__exportStar(require("./ZodDef"), exports);
__exportStar(require("./ZodError"), exports);
//# sourceMappingURL=index.js.map

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

import { ZodType } from './types/base';
export declare const isScalar: (schema: ZodType<any, any, any>, params?: {
import { ZodType } from ".";
export declare const isScalar: (schema: ZodType<any, any>, params?: {
root: boolean;
}) => boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isScalar = void 0;
var _1 = require(".");
var util_1 = require("./helpers/util");
var base_1 = require("./types/base");
exports.isScalar = function (schema, params) {
var isScalar = function (schema, params) {
if (params === void 0) { params = { root: true }; }

@@ -10,33 +11,33 @@ var def = schema._def;

switch (def.t) {
case base_1.ZodTypes.string:
case _1.ZodTypes.string:
returnValue = true;
break;
case base_1.ZodTypes.number:
case _1.ZodTypes.number:
returnValue = true;
break;
case base_1.ZodTypes.bigint:
case _1.ZodTypes.bigint:
returnValue = true;
break;
case base_1.ZodTypes.boolean:
case _1.ZodTypes.boolean:
returnValue = true;
break;
case base_1.ZodTypes.undefined:
case _1.ZodTypes.undefined:
returnValue = true;
break;
case base_1.ZodTypes.null:
case _1.ZodTypes.null:
returnValue = true;
break;
case base_1.ZodTypes.any:
case _1.ZodTypes.any:
returnValue = false;
break;
case base_1.ZodTypes.unknown:
case _1.ZodTypes.unknown:
returnValue = false;
break;
case base_1.ZodTypes.never:
case _1.ZodTypes.never:
returnValue = false;
break;
case base_1.ZodTypes.void:
case _1.ZodTypes.void:
returnValue = false;
break;
case base_1.ZodTypes.array:
case _1.ZodTypes.array:
if (params.root === false)

@@ -46,48 +47,48 @@ return false;

break;
case base_1.ZodTypes.object:
case _1.ZodTypes.object:
returnValue = false;
break;
case base_1.ZodTypes.union:
case _1.ZodTypes.union:
returnValue = def.options.every(function (x) { return exports.isScalar(x); });
break;
case base_1.ZodTypes.intersection:
case _1.ZodTypes.intersection:
returnValue = exports.isScalar(def.left) && exports.isScalar(def.right);
break;
case base_1.ZodTypes.tuple:
case _1.ZodTypes.tuple:
returnValue = def.items.every(function (x) { return exports.isScalar(x, { root: false }); });
break;
case base_1.ZodTypes.lazy:
case _1.ZodTypes.lazy:
returnValue = exports.isScalar(def.getter());
break;
case base_1.ZodTypes.literal:
case _1.ZodTypes.literal:
returnValue = true;
break;
case base_1.ZodTypes.enum:
case _1.ZodTypes.enum:
returnValue = true;
break;
case base_1.ZodTypes.nativeEnum:
case _1.ZodTypes.nativeEnum:
returnValue = true;
break;
case base_1.ZodTypes.function:
case _1.ZodTypes.function:
returnValue = false;
break;
case base_1.ZodTypes.record:
case _1.ZodTypes.record:
returnValue = false;
break;
case base_1.ZodTypes.map:
case _1.ZodTypes.map:
returnValue = false;
break;
case base_1.ZodTypes.date:
case _1.ZodTypes.date:
returnValue = true;
break;
case base_1.ZodTypes.promise:
case _1.ZodTypes.promise:
returnValue = false;
break;
case base_1.ZodTypes.transformer:
case _1.ZodTypes.transformer:
returnValue = exports.isScalar(def.output);
break;
case base_1.ZodTypes.optional:
case _1.ZodTypes.optional:
returnValue = exports.isScalar(def.innerType);
break;
case base_1.ZodTypes.nullable:
case _1.ZodTypes.nullable:
returnValue = exports.isScalar(def.innerType);

@@ -100,2 +101,3 @@ break;

};
exports.isScalar = isScalar;
//# sourceMappingURL=isScalar.js.map

@@ -1,34 +0,9 @@

import * as z from './types/base';
import { ZodError, ZodIssueOptionalMessage } from './ZodError';
import { util } from './helpers/util';
import { ZodErrorMap } from './defaultErrorMap';
export declare const getParsedType: (data: any) => "number" | "string" | "nan" | "integer" | "boolean" | "date" | "bigint" | "symbol" | "function" | "undefined" | "null" | "array" | "object" | "unknown" | "promise" | "void" | "never" | "map";
export declare const ZodParsedType: {
number: "number";
string: "string";
nan: "nan";
integer: "integer";
boolean: "boolean";
date: "date";
bigint: "bigint";
symbol: "symbol";
function: "function";
undefined: "undefined";
null: "null";
array: "array";
object: "object";
unknown: "unknown";
promise: "promise";
void: "void";
never: "never";
map: "map";
};
export declare type ZodParsedType = keyof typeof ZodParsedType;
declare type stripPath<T extends object> = T extends any ? util.OmitKeys<T, 'path'> : never;
export declare type MakeErrorData = stripPath<ZodIssueOptionalMessage> & {
path?: (string | number)[];
};
import { ZodErrorMap } from "./defaultErrorMap";
import { ZodType } from ".";
import { ZodError } from "./ZodError";
import { ZodParsedType } from "./ZodParsedType";
export declare const getParsedType: (data: any) => ZodParsedType;
export declare type ParseParams = {
seen?: {
schema: z.ZodType<any>;
schema: ZodType<any>;
objects: {

@@ -45,3 +20,2 @@ input: any;

};
export declare const ZodParser: (schema: z.ZodType<any, z.ZodTypeDef, any>) => (data: any, baseParams?: ParseParams) => any;
export {};
export declare const ZodParser: (schema: ZodType<any>) => (data: any, baseParams?: ParseParams) => any;

@@ -80,76 +80,51 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./types/base"));
var ZodError_1 = require("./ZodError");
exports.ZodParser = exports.getParsedType = void 0;
var defaultErrorMap_1 = require("./defaultErrorMap");
var util_1 = require("./helpers/util");
var defaultErrorMap_1 = require("./defaultErrorMap");
var PseudoPromise_1 = require("./PseudoPromise");
var index_1 = require("./index");
exports.getParsedType = function (data) {
if (typeof data === 'string')
return 'string';
if (typeof data === 'number') {
var ZodError_1 = require("./ZodError");
var ZodParsedType_1 = require("./ZodParsedType");
var ZodTypes_1 = require("./ZodTypes");
var getParsedType = function (data) {
if (typeof data === "string")
return "string";
if (typeof data === "number") {
if (Number.isNaN(data))
return 'nan';
return 'number';
return "nan";
return "number";
}
if (typeof data === 'boolean')
return 'boolean';
if (typeof data === 'bigint')
return 'bigint';
if (typeof data === 'symbol')
return 'symbol';
if (typeof data === "boolean")
return "boolean";
if (typeof data === "bigint")
return "bigint";
if (typeof data === "symbol")
return "symbol";
if (data instanceof Date)
return 'date';
if (typeof data === 'function')
return 'function';
return "date";
if (typeof data === "function")
return "function";
if (data === undefined)
return 'undefined';
if (typeof data === 'undefined')
return 'undefined';
if (typeof data === 'object') {
return "undefined";
if (typeof data === "undefined")
return "undefined";
if (typeof data === "object") {
if (Array.isArray(data))
return 'array';
return "array";
if (data === null)
return 'null';
return "null";
if (data.then &&
typeof data.then === 'function' &&
typeof data.then === "function" &&
data.catch &&
typeof data.catch === 'function') {
return 'promise';
typeof data.catch === "function") {
return "promise";
}
if (data instanceof Map) {
return 'map';
return "map";
}
return 'object';
return "object";
}
return 'unknown';
return "unknown";
};
exports.ZodParsedType = util_1.util.arrayToEnum([
'string',
'nan',
'number',
'integer',
'boolean',
'date',
'bigint',
'symbol',
'function',
'undefined',
'null',
'array',
'object',
'unknown',
'promise',
'void',
'never',
'map',
]);
exports.getParsedType = getParsedType;
var makeError = function (params, data, errorData) {

@@ -164,6 +139,6 @@ var errorArg = __assign(__assign({}, errorData), { path: __spread(params.path, (errorData.path || [])) });

};
exports.ZodParser = function (schema) { return function (data, baseParams) {
var ZodParser = function (schema) { return function (data, baseParams) {
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
var _e, _f;
if (baseParams === void 0) { baseParams = { seen: [], errorMap: defaultErrorMap_1.defaultErrorMap, path: [] }; }
var _e, _f;
var params = {

@@ -198,7 +173,7 @@ seen: baseParams.seen || [],

switch (def.t) {
case z.ZodTypes.string:
if (parsedType !== exports.ZodParsedType.string) {
case ZodTypes_1.ZodTypes.string:
if (parsedType !== ZodParsedType_1.ZodParsedType.string) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.string,
expected: ZodParsedType_1.ZodParsedType.string,
received: parsedType,

@@ -210,7 +185,7 @@ }));

break;
case z.ZodTypes.number:
if (parsedType !== exports.ZodParsedType.number) {
case ZodTypes_1.ZodTypes.number:
if (parsedType !== ZodParsedType_1.ZodParsedType.number) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.number,
expected: ZodParsedType_1.ZodParsedType.number,
received: parsedType,

@@ -223,4 +198,4 @@ }));

code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.number,
received: exports.ZodParsedType.nan,
expected: ZodParsedType_1.ZodParsedType.number,
received: ZodParsedType_1.ZodParsedType.nan,
}));

@@ -231,7 +206,7 @@ THROW();

break;
case z.ZodTypes.bigint:
if (parsedType !== exports.ZodParsedType.bigint) {
case ZodTypes_1.ZodTypes.bigint:
if (parsedType !== ZodParsedType_1.ZodParsedType.bigint) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.bigint,
expected: ZodParsedType_1.ZodParsedType.bigint,
received: parsedType,

@@ -243,7 +218,7 @@ }));

break;
case z.ZodTypes.boolean:
if (parsedType !== exports.ZodParsedType.boolean) {
case ZodTypes_1.ZodTypes.boolean:
if (parsedType !== ZodParsedType_1.ZodParsedType.boolean) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.boolean,
expected: ZodParsedType_1.ZodParsedType.boolean,
received: parsedType,

@@ -255,7 +230,7 @@ }));

break;
case z.ZodTypes.undefined:
if (parsedType !== exports.ZodParsedType.undefined) {
case ZodTypes_1.ZodTypes.undefined:
if (parsedType !== ZodParsedType_1.ZodParsedType.undefined) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.undefined,
expected: ZodParsedType_1.ZodParsedType.undefined,
received: parsedType,

@@ -267,7 +242,7 @@ }));

break;
case z.ZodTypes.null:
if (parsedType !== exports.ZodParsedType.null) {
case ZodTypes_1.ZodTypes.null:
if (parsedType !== ZodParsedType_1.ZodParsedType.null) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.null,
expected: ZodParsedType_1.ZodParsedType.null,
received: parsedType,

@@ -279,12 +254,12 @@ }));

break;
case z.ZodTypes.any:
case ZodTypes_1.ZodTypes.any:
PROMISE = PseudoPromise_1.PseudoPromise.resolve(data);
break;
case z.ZodTypes.unknown:
case ZodTypes_1.ZodTypes.unknown:
PROMISE = PseudoPromise_1.PseudoPromise.resolve(data);
break;
case z.ZodTypes.never:
case ZodTypes_1.ZodTypes.never:
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.never,
expected: ZodParsedType_1.ZodParsedType.never,
received: parsedType,

@@ -294,8 +269,8 @@ }));

break;
case z.ZodTypes.void:
if (parsedType !== exports.ZodParsedType.undefined &&
parsedType !== exports.ZodParsedType.null) {
case ZodTypes_1.ZodTypes.void:
if (parsedType !== ZodParsedType_1.ZodParsedType.undefined &&
parsedType !== ZodParsedType_1.ZodParsedType.null) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.void,
expected: ZodParsedType_1.ZodParsedType.void,
received: parsedType,

@@ -307,8 +282,8 @@ }));

break;
case z.ZodTypes.array:
case ZodTypes_1.ZodTypes.array:
RESULT.output = [];
if (parsedType !== exports.ZodParsedType.array) {
if (parsedType !== ZodParsedType_1.ZodParsedType.array) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.array,
expected: ZodParsedType_1.ZodParsedType.array,
received: parsedType,

@@ -338,7 +313,7 @@ }));

break;
case z.ZodTypes.map:
if (parsedType !== exports.ZodParsedType.map) {
case ZodTypes_1.ZodTypes.map:
if (parsedType !== ZodParsedType_1.ZodParsedType.map) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.map,
expected: ZodParsedType_1.ZodParsedType.map,
received: parsedType,

@@ -355,3 +330,3 @@ }));

.then(function () {
return def.keyType.parse(key, __assign(__assign({}, params), { path: __spread(params.path, [index, 'key']) }));
return def.keyType.parse(key, __assign(__assign({}, params), { path: __spread(params.path, [index, "key"]) }));
})

@@ -361,3 +336,3 @@ .catch(HANDLE),

.then(function () {
var mapValue = def.valueType.parse(value, __assign(__assign({}, params), { path: __spread(params.path, [index, 'value']) }));
var mapValue = def.valueType.parse(value, __assign(__assign({}, params), { path: __spread(params.path, [index, "value"]) }));
return [key, mapValue];

@@ -386,8 +361,8 @@ })

break;
case z.ZodTypes.object:
case ZodTypes_1.ZodTypes.object:
RESULT.output = {};
if (parsedType !== exports.ZodParsedType.object) {
if (parsedType !== ZodParsedType_1.ZodParsedType.object) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.object,
expected: ZodParsedType_1.ZodParsedType.object,
received: parsedType,

@@ -405,3 +380,3 @@ }));

? shape[key]
: !(def.catchall instanceof index_1.ZodNever)
: !(def.catchall._def.t === ZodTypes_1.ZodTypes.never)
? def.catchall

@@ -412,3 +387,3 @@ : undefined;

}
if (typeof data[key] === 'undefined' && !dataKeys.includes(key)) {
if (typeof data[key] === "undefined" && !dataKeys.includes(key)) {
objectPromises_1[key] = new PseudoPromise_1.PseudoPromise()

@@ -466,4 +441,4 @@ .then(function () {

}
if (def.catchall instanceof index_1.ZodNever) {
if (def.unknownKeys === 'passthrough') {
if (def.catchall._def.t === ZodTypes_1.ZodTypes.never) {
if (def.unknownKeys === "passthrough") {
try {

@@ -483,3 +458,3 @@ for (var extraKeys_1 = __values(extraKeys), extraKeys_1_1 = extraKeys_1.next(); !extraKeys_1_1.done; extraKeys_1_1 = extraKeys_1.next()) {

}
else if (def.unknownKeys === 'strict') {
else if (def.unknownKeys === "strict") {
if (extraKeys.length > 0) {

@@ -492,3 +467,3 @@ ERROR.addIssue(makeError(params, data, {

}
else if (def.unknownKeys === 'strip') {
else if (def.unknownKeys === "strip") {
}

@@ -548,3 +523,3 @@ else {

break;
case z.ZodTypes.union:
case ZodTypes_1.ZodTypes.union:
var isValid_1 = false;

@@ -572,3 +547,3 @@ var unionErrors_1 = [];

var nonTypeErrors = unionErrors_1.filter(function (err) {
return err.issues[0].code !== 'invalid_type';
return err.issues[0].code !== "invalid_type";
});

@@ -592,3 +567,3 @@ if (nonTypeErrors.length === 1) {

break;
case z.ZodTypes.intersection:
case ZodTypes_1.ZodTypes.intersection:
PROMISE = PseudoPromise_1.PseudoPromise.all([

@@ -614,4 +589,4 @@ new PseudoPromise_1.PseudoPromise()

}
else if (parsedLeftType === exports.ZodParsedType.object &&
parsedRightType === exports.ZodParsedType.object) {
else if (parsedLeftType === ZodParsedType_1.ZodParsedType.object &&
parsedRightType === ZodParsedType_1.ZodParsedType.object) {
return __assign(__assign({}, parsedLeft), parsedRight);

@@ -626,4 +601,4 @@ }

break;
case z.ZodTypes.optional:
if (parsedType === exports.ZodParsedType.undefined) {
case ZodTypes_1.ZodTypes.optional:
if (parsedType === ZodParsedType_1.ZodParsedType.undefined) {
PROMISE = PseudoPromise_1.PseudoPromise.resolve(undefined);

@@ -638,4 +613,4 @@ break;

break;
case z.ZodTypes.nullable:
if (parsedType === exports.ZodParsedType.null) {
case ZodTypes_1.ZodTypes.nullable:
if (parsedType === ZodParsedType_1.ZodParsedType.null) {
PROMISE = PseudoPromise_1.PseudoPromise.resolve(null);

@@ -650,7 +625,7 @@ break;

break;
case z.ZodTypes.tuple:
if (parsedType !== exports.ZodParsedType.array) {
case ZodTypes_1.ZodTypes.tuple:
if (parsedType !== ZodParsedType_1.ZodParsedType.array) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.array,
expected: ZodParsedType_1.ZodParsedType.array,
received: parsedType,

@@ -665,3 +640,3 @@ }));

inclusive: true,
type: 'array',
type: "array",
}));

@@ -674,3 +649,3 @@ }

inclusive: true,
type: 'array',
type: "array",
}));

@@ -706,7 +681,7 @@ }

break;
case z.ZodTypes.lazy:
case ZodTypes_1.ZodTypes.lazy:
var lazySchema = def.getter();
PROMISE = PseudoPromise_1.PseudoPromise.resolve(lazySchema.parse(data, params));
break;
case z.ZodTypes.literal:
case ZodTypes_1.ZodTypes.literal:
if (data !== def.value) {

@@ -720,3 +695,3 @@ ERROR.addIssue(makeError(params, data, {

break;
case z.ZodTypes.enum:
case ZodTypes_1.ZodTypes.enum:
if (def.values.indexOf(data) === -1) {

@@ -730,3 +705,3 @@ ERROR.addIssue(makeError(params, data, {

break;
case z.ZodTypes.nativeEnum:
case ZodTypes_1.ZodTypes.nativeEnum:
if (util_1.util.getValidEnumValues(def.values).indexOf(data) === -1) {

@@ -740,7 +715,7 @@ ERROR.addIssue(makeError(params, data, {

break;
case z.ZodTypes.function:
if (parsedType !== exports.ZodParsedType.function) {
case ZodTypes_1.ZodTypes.function:
if (parsedType !== ZodParsedType_1.ZodParsedType.function) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.function,
expected: ZodParsedType_1.ZodParsedType.function,
received: parsedType,

@@ -750,3 +725,3 @@ }));

}
var isAsyncFunction_1 = def.returns instanceof index_1.ZodPromise;
var isAsyncFunction_1 = def.returns._def.t === ZodTypes_1.ZodTypes.promise;
var validatedFunction = function () {

@@ -797,7 +772,7 @@ var args = [];

break;
case z.ZodTypes.record:
if (parsedType !== exports.ZodParsedType.object) {
case ZodTypes_1.ZodTypes.record:
if (parsedType !== ZodParsedType_1.ZodParsedType.object) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.object,
expected: ZodParsedType_1.ZodParsedType.object,
received: parsedType,

@@ -820,7 +795,7 @@ }));

break;
case z.ZodTypes.date:
case ZodTypes_1.ZodTypes.date:
if (!(data instanceof Date)) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.date,
expected: ZodParsedType_1.ZodParsedType.date,
received: parsedType,

@@ -838,7 +813,7 @@ }));

break;
case z.ZodTypes.promise:
if (parsedType !== exports.ZodParsedType.promise && params.async !== true) {
case ZodTypes_1.ZodTypes.promise:
if (parsedType !== ZodParsedType_1.ZodParsedType.promise && params.async !== true) {
ERROR.addIssue(makeError(params, data, {
code: ZodError_1.ZodIssueCode.invalid_type,
expected: exports.ZodParsedType.promise,
expected: ZodParsedType_1.ZodParsedType.promise,
received: parsedType,

@@ -848,3 +823,3 @@ }));

}
var promisified = parsedType === exports.ZodParsedType.promise ? data : Promise.resolve(data);
var promisified = parsedType === ZodParsedType_1.ZodParsedType.promise ? data : Promise.resolve(data);
PROMISE = PseudoPromise_1.PseudoPromise.resolve(promisified.then(function (resolvedData) {

@@ -854,3 +829,3 @@ return def.type.parse(resolvedData, params);

break;
case z.ZodTypes.transformer:
case ZodTypes_1.ZodTypes.transformer:
PROMISE = new PseudoPromise_1.PseudoPromise()

@@ -863,3 +838,3 @@ .then(function () {

if (transformed instanceof Promise && params.async === false) {
if (z.inputSchema(def.output)._def.t !== z.ZodTypes.promise) {
if (def.output._def.t !== ZodTypes_1.ZodTypes.promise) {
throw new Error("You can't call .parse on a schema containing async transformations.");

@@ -875,7 +850,7 @@ }

default:
PROMISE = PseudoPromise_1.PseudoPromise.resolve('adsf');
PROMISE = PseudoPromise_1.PseudoPromise.resolve("adsf");
util_1.util.assertNever(def);
}
if (PROMISE._default === true) {
throw new Error('Result is not materialized.');
throw new Error("Result is not materialized.");
}

@@ -897,3 +872,3 @@ if (!ERROR.isEmpty) {

code: ZodError_1.ZodIssueCode.custom,
message: 'Invalid',
message: "Invalid",
}));

@@ -935,3 +910,3 @@ }

code: ZodError_1.ZodIssueCode.custom,
message: 'Invalid',
message: "Invalid",
}));

@@ -990,2 +965,3 @@ }

}; };
exports.ZodParser = ZodParser;
//# sourceMappingURL=parser.js.map

@@ -5,3 +5,3 @@ declare type Func = (arg: any, ctx: {

declare type FuncItem = {
type: 'function';
type: "function";
function: Func;

@@ -13,3 +13,3 @@ };

declare type CatcherItem = {
type: 'catcher';
type: "catcher";
catcher: Catcher;

@@ -16,0 +16,0 @@ };

@@ -70,5 +70,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PseudoPromise = exports.NOSET = void 0;
var util_1 = require("./helpers/util");
var ZodError_1 = require("./ZodError");
exports.NOSET = Symbol('no_set');
exports.NOSET = Symbol("no_set");
var PseudoPromise = (function () {

@@ -109,3 +110,3 @@ function PseudoPromise(funcs) {

return new PseudoPromise(__spread(_this.items, [
{ type: 'function', function: func },
{ type: "function", function: func },
]));

@@ -115,3 +116,3 @@ };

return new PseudoPromise(__spread(_this.items, [
{ type: 'catcher', catcher: catcher },
{ type: "catcher", catcher: catcher },
]));

@@ -124,3 +125,3 @@ };

var item = _this.items[index];
if (item.type === 'function') {
if (item.type === "function") {
val = item.function(val, { async: false });

@@ -130,5 +131,5 @@ }

catch (err) {
var catcherIndex = _this.items.findIndex(function (x, i) { return x.type === 'catcher' && i > index; });
var catcherIndex = _this.items.findIndex(function (x, i) { return x.type === "catcher" && i > index; });
var catcherItem = _this.items[catcherIndex];
if (!catcherItem || catcherItem.type !== 'catcher') {
if (!catcherItem || catcherItem.type !== "catcher") {
throw err;

@@ -165,3 +166,3 @@ }

_a.trys.push([1, 4, , 8]);
if (!(item.type === 'function')) return [3, 3];
if (!(item.type === "function")) return [3, 3];
return [4, item.function(val, { async: true })];

@@ -174,5 +175,5 @@ case 2:

err_2 = _a.sent();
catcherIndex = this_1.items.findIndex(function (x, i) { return x.type === 'catcher' && i > index; });
catcherIndex = this_1.items.findIndex(function (x, i) { return x.type === "catcher" && i > index; });
catcherItem = this_1.items[catcherIndex];
if (!(!catcherItem || catcherItem.type !== 'catcher')) return [3, 5];
if (!(!catcherItem || catcherItem.type !== "catcher")) return [3, 5];
throw err_2;

@@ -188,6 +189,6 @@ case 5:

if (val instanceof PseudoPromise) {
throw new Error('ASYNC: DO NOT RETURN PSEUDOPROMISE FROM FUNCTIONS');
throw new Error("ASYNC: DO NOT RETURN PSEUDOPROMISE FROM FUNCTIONS");
}
if (val instanceof Promise) {
throw new Error('ASYNC: DO NOT RETURN PROMISE FROM FUNCTIONS');
throw new Error("ASYNC: DO NOT RETURN PROMISE FROM FUNCTIONS");
}

@@ -313,3 +314,3 @@ out_index_2 = index;

if (value instanceof PseudoPromise) {
throw new Error('Do not pass PseudoPromise into PseudoPromise.resolve');
throw new Error("Do not pass PseudoPromise into PseudoPromise.resolve");
}

@@ -316,0 +317,0 @@ return new PseudoPromise().then(function () { return value; });

@@ -1,2 +0,2 @@

import * as z from './index';
export declare const visitor: (schema: z.ZodType<any, any, any>) => void;
import { ZodType } from ".";
export declare const visitor: (schema: ZodType<any, any>) => void;
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./index"));
exports.visitor = void 0;
var util_1 = require("./helpers/util");
exports.visitor = function (schema) {
var _1 = require(".");
var visitor = function (schema) {
var def = schema._def;
switch (def.t) {
case z.ZodTypes.string:
case _1.ZodTypes.string:
break;
case z.ZodTypes.number:
case _1.ZodTypes.number:
break;
case z.ZodTypes.bigint:
case _1.ZodTypes.bigint:
break;
case z.ZodTypes.boolean:
case _1.ZodTypes.boolean:
break;
case z.ZodTypes.undefined:
case _1.ZodTypes.undefined:
break;
case z.ZodTypes.null:
case _1.ZodTypes.null:
break;
case z.ZodTypes.any:
case _1.ZodTypes.any:
break;
case z.ZodTypes.unknown:
case _1.ZodTypes.unknown:
break;
case z.ZodTypes.never:
case _1.ZodTypes.never:
break;
case z.ZodTypes.void:
case _1.ZodTypes.void:
break;
case z.ZodTypes.array:
case _1.ZodTypes.array:
break;
case z.ZodTypes.object:
case _1.ZodTypes.object:
break;
case z.ZodTypes.union:
case _1.ZodTypes.union:
break;
case z.ZodTypes.intersection:
case _1.ZodTypes.intersection:
break;
case z.ZodTypes.tuple:
case _1.ZodTypes.tuple:
break;
case z.ZodTypes.lazy:
case _1.ZodTypes.lazy:
break;
case z.ZodTypes.literal:
case _1.ZodTypes.literal:
break;
case z.ZodTypes.enum:
case _1.ZodTypes.enum:
break;
case z.ZodTypes.nativeEnum:
case _1.ZodTypes.nativeEnum:
break;
case z.ZodTypes.function:
case _1.ZodTypes.function:
break;
case z.ZodTypes.record:
case _1.ZodTypes.record:
break;
case z.ZodTypes.date:
case _1.ZodTypes.date:
break;
case z.ZodTypes.promise:
case _1.ZodTypes.promise:
break;
case z.ZodTypes.transformer:
case _1.ZodTypes.transformer:
break;
case z.ZodTypes.optional:
case _1.ZodTypes.optional:
break;
case z.ZodTypes.nullable:
case _1.ZodTypes.nullable:
break;
case z.ZodTypes.map:
case _1.ZodTypes.map:
break;

@@ -73,2 +67,3 @@ default:

};
exports.visitor = visitor;
//# sourceMappingURL=switcher.js.map

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

import * as z from './base';
export interface ZodAnyDef extends z.ZodTypeDef {
t: z.ZodTypes.any;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodAnyDef extends ZodTypeDef {
t: ZodTypes.any;
}
export declare class ZodAny extends z.ZodType<any, ZodAnyDef> {
export declare class ZodAny extends ZodType<any, ZodAnyDef> {
toJSON: () => ZodAnyDef;
static create: () => ZodAny;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodAny = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodAny = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodAny, _super);

return new ZodAny({
t: z.ZodTypes.any,
t: ZodTypes_1.ZodTypes.any,
});
};
return ZodAny;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodAny = ZodAny;
//# sourceMappingURL=any.js.map

@@ -1,10 +0,11 @@

import * as z from './base';
export interface ZodArrayDef<T extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.array;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.array;
type: T;
nonempty: boolean;
}
export declare class ZodArray<T extends z.ZodTypeAny> extends z.ZodType<T['_output'][], ZodArrayDef<T>, T['_input'][]> {
export declare class ZodArray<T extends ZodTypeAny> extends ZodType<T["_output"][], ZodArrayDef<T>, T["_input"][]> {
toJSON: () => {
t: z.ZodTypes.array;
t: ZodTypes.array;
nonempty: boolean;

@@ -22,7 +23,13 @@ type: object;

nonempty: () => ZodNonEmptyArray<T>;
static create: <T_1 extends z.ZodTypeAny>(schema: T_1) => ZodArray<T_1>;
static create: <T_1 extends ZodTypeAny>(schema: T_1) => ZodArray<T_1>;
}
export declare class ZodNonEmptyArray<T extends z.ZodTypeAny> extends z.ZodType<[T['_output'], ...T['_output'][]], ZodArrayDef<T>, [T['_input'], ...T['_input'][]]> {
export declare class ZodNonEmptyArray<T extends ZodTypeAny> extends ZodType<[
T["_output"],
...T["_output"][]
], ZodArrayDef<T>, [
T["_input"],
...T["_input"][]
]> {
toJSON: () => {
t: z.ZodTypes.array;
t: ZodTypes.array;
type: object;

@@ -29,0 +36,0 @@ };

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -27,12 +27,7 @@ };

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodNonEmptyArray = exports.ZodArray = void 0;
var ZodError_1 = require("../ZodError");
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodArray = (function (_super) {

@@ -50,6 +45,6 @@ __extends(ZodArray, _super);

_this.min = function (minLength, message) {
return _this.refinement(function (data) { return data.length >= minLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, type: 'array', inclusive: true, minimum: minLength }, (typeof message === 'string' ? { message: message } : message)));
return _this.refinement(function (data) { return data.length >= minLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, type: "array", inclusive: true, minimum: minLength }, (typeof message === "string" ? { message: message } : message)));
};
_this.max = function (maxLength, message) {
return _this.refinement(function (data) { return data.length <= maxLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, type: 'array', inclusive: true, maximum: maxLength }, (typeof message === 'string' ? { message: message } : message)));
return _this.refinement(function (data) { return data.length <= maxLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, type: "array", inclusive: true, maximum: maxLength }, (typeof message === "string" ? { message: message } : message)));
};

@@ -68,3 +63,3 @@ _this.length = function (len, message) {

},
enumerable: true,
enumerable: false,
configurable: true

@@ -74,3 +69,3 @@ });

return new ZodArray({
t: z.ZodTypes.array,
t: ZodTypes_1.ZodTypes.array,
type: schema,

@@ -81,3 +76,3 @@ nonempty: false,

return ZodArray;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodArray = ZodArray;

@@ -95,6 +90,6 @@ var ZodNonEmptyArray = (function (_super) {

_this.min = function (minLength, message) {
return _this.refinement(function (data) { return data.length >= minLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: minLength, type: 'array', inclusive: true }, (typeof message === 'string' ? { message: message } : message)));
return _this.refinement(function (data) { return data.length >= minLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: minLength, type: "array", inclusive: true }, (typeof message === "string" ? { message: message } : message)));
};
_this.max = function (maxLength, message) {
return _this.refinement(function (data) { return data.length <= maxLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: maxLength, type: 'array', inclusive: true }, (typeof message === 'string' ? { message: message } : message)));
return _this.refinement(function (data) { return data.length <= maxLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: maxLength, type: "array", inclusive: true }, (typeof message === "string" ? { message: message } : message)));
};

@@ -107,4 +102,4 @@ _this.length = function (len, message) {

return ZodNonEmptyArray;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodNonEmptyArray = ZodNonEmptyArray;
//# sourceMappingURL=array.js.map

@@ -1,40 +0,5 @@

import { ParseParams, MakeErrorData } from '../parser';
import { ZodArray, ZodTransformer, ZodError, ZodCustomIssue } from '../index';
import { ZodOptionalType } from './optional';
import { ZodNullableType } from './nullable';
export declare enum ZodTypes {
string = "string",
number = "number",
bigint = "bigint",
boolean = "boolean",
date = "date",
undefined = "undefined",
null = "null",
array = "array",
object = "object",
union = "union",
intersection = "intersection",
tuple = "tuple",
record = "record",
map = "map",
function = "function",
lazy = "lazy",
literal = "literal",
enum = "enum",
nativeEnum = "nativeEnum",
promise = "promise",
any = "any",
unknown = "unknown",
never = "never",
void = "void",
transformer = "transformer",
optional = "optional",
nullable = "nullable"
}
export declare type ZodTypeAny = ZodType<any, any, any>;
export declare type ZodRawShape = {
[k: string]: ZodTypeAny;
};
export declare const inputSchema: (schema: ZodType<any, ZodTypeDef, any>) => ZodType<any, ZodTypeDef, any>;
export declare const outputSchema: (schema: ZodType<any, ZodTypeDef, any>) => ZodType<any, ZodTypeDef, any>;
import { util } from "../helpers/util";
import { ZodTypes } from "../ZodTypes";
import { ParseParams } from "../parser";
import { ZodCustomIssue, ZodError, MakeErrorData } from "../ZodError";
export declare type RefinementCtx = {

@@ -44,5 +9,16 @@ addIssue: (arg: MakeErrorData) => void;

};
export declare type ZodRawShape = {
[k: string]: ZodTypeAny;
};
export declare type TypeOf<T extends ZodType<any>> = T["_output"];
export declare type input<T extends ZodType<any>> = T["_input"];
export declare type output<T extends ZodType<any>> = T["_output"];
export declare type infer<T extends ZodType<any>> = T["_output"];
export declare type ZodTypeAny = ZodType<any, any, any>;
import { ZodArray, ZodNullableType, ZodOptionalType, ZodTransformer } from "../index";
declare type CustomErrorParams = Partial<util.Omit<ZodCustomIssue, "code">>;
declare type InternalCheck<T> = {
check: (arg: T, ctx: RefinementCtx) => any;
};
export declare function declareZodType(): void;
export interface ZodTypeDef {

@@ -53,11 +29,7 @@ t: ZodTypes;

}
export declare type TypeOf<T extends ZodType<any>> = T['_output'];
export declare type input<T extends ZodType<any>> = T['_input'];
export declare type output<T extends ZodType<any>> = T['_output'];
export declare type infer<T extends ZodType<any>> = T['_output'];
export declare abstract class ZodType<Output, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
readonly _type: Output;
readonly _output: Output;
readonly _input: Input;
readonly _def: Def;
readonly _input: Input;
parse: (x: unknown, params?: ParseParams) => Output;

@@ -88,3 +60,3 @@ safeParse: (x: unknown, params?: ParseParams) => {

check(u: unknown): u is Input;
refine: <Func extends (arg: Output) => any>(check: Func, message?: string | Partial<Pick<ZodCustomIssue, "path" | "message" | "params">> | ((arg: Output) => Partial<Pick<ZodCustomIssue, "path" | "message" | "params">>)) => this;
refine: <Func extends (arg: Output) => any>(check: Func, message?: string | Partial<Pick<ZodCustomIssue, "path" | "message" | "params">> | ((arg: Output) => CustomErrorParams)) => this;
refinement: (check: (arg: Output) => any, refinementData: (Pick<import("..").ZodInvalidTypeIssue, "code" | "expected" | "received" | "message"> & {

@@ -119,3 +91,3 @@ path?: (string | number)[] | undefined;

}) | ((arg: Output, ctx: RefinementCtx) => MakeErrorData)) => this;
_refinement: (refinement: InternalCheck<Output>['check']) => this;
_refinement: (refinement: InternalCheck<Output>["check"]) => this;
constructor(def: Def);

@@ -127,6 +99,6 @@ abstract toJSON: () => object;

array: () => ZodArray<this>;
transform<This extends this, U extends ZodType<any>, Tx extends (arg: This['_output']) => U['_input'] | Promise<U['_input']>>(input: U, transformer: Tx): ZodTransformer<This, U>;
transform<This extends this, Tx extends (arg: This['_output']) => This['_output'] | Promise<This['_output']>>(transformer: Tx): ZodTransformer<This, This>;
default<T extends Input = Input, Opt extends ReturnType<this['optional']> = ReturnType<this['optional']>>(def: T): ZodTransformer<Opt, this>;
default<T extends (arg: this) => Input, Opt extends ReturnType<this['optional']> = ReturnType<this['optional']>>(def: T): ZodTransformer<Opt, this>;
transform<This extends this, U extends ZodType<any>, Tx extends (arg: This["_output"]) => U["_input"] | Promise<U["_input"]>>(input: U, transformer: Tx): ZodTransformer<This, U>;
transform<This extends this, Tx extends (arg: This["_output"]) => This["_output"] | Promise<This["_output"]>>(transformer: Tx): ZodTransformer<This, This>;
default<T extends Input = Input, Opt extends ReturnType<this["optional"]> = ReturnType<this["optional"]>>(def: T): ZodTransformer<Opt, this>;
default<T extends (arg: this) => Input, Opt extends ReturnType<this["optional"]> = ReturnType<this["optional"]>>(def: T): ZodTransformer<Opt, this>;
isOptional: () => boolean;

@@ -133,0 +105,0 @@ isNullable: () => boolean;

@@ -70,50 +70,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ZodType = exports.declareZodType = void 0;
var parser_1 = require("../parser");
var ZodError_1 = require("../ZodError");
var index_1 = require("../index");
var ZodTypes;
(function (ZodTypes) {
ZodTypes["string"] = "string";
ZodTypes["number"] = "number";
ZodTypes["bigint"] = "bigint";
ZodTypes["boolean"] = "boolean";
ZodTypes["date"] = "date";
ZodTypes["undefined"] = "undefined";
ZodTypes["null"] = "null";
ZodTypes["array"] = "array";
ZodTypes["object"] = "object";
ZodTypes["union"] = "union";
ZodTypes["intersection"] = "intersection";
ZodTypes["tuple"] = "tuple";
ZodTypes["record"] = "record";
ZodTypes["map"] = "map";
ZodTypes["function"] = "function";
ZodTypes["lazy"] = "lazy";
ZodTypes["literal"] = "literal";
ZodTypes["enum"] = "enum";
ZodTypes["nativeEnum"] = "nativeEnum";
ZodTypes["promise"] = "promise";
ZodTypes["any"] = "any";
ZodTypes["unknown"] = "unknown";
ZodTypes["never"] = "never";
ZodTypes["void"] = "void";
ZodTypes["transformer"] = "transformer";
ZodTypes["optional"] = "optional";
ZodTypes["nullable"] = "nullable";
})(ZodTypes = exports.ZodTypes || (exports.ZodTypes = {}));
exports.inputSchema = function (schema) {
if (schema instanceof index_1.ZodTransformer) {
return exports.inputSchema(schema._def.input);
}
else {
return schema;
}
};
exports.outputSchema = function (schema) {
if (schema instanceof index_1.ZodTransformer) {
return exports.inputSchema(schema._def.output);
}
else {
return schema;
}
};
function declareZodType() { }
exports.declareZodType = declareZodType;
var ZodType = (function () {

@@ -129,3 +87,3 @@ function ZodType(def) {

catch (err) {
if (err instanceof index_1.ZodError) {
if (err instanceof ZodError_1.ZodError) {
return { success: false, error: err };

@@ -156,3 +114,3 @@ }

err_1 = _a.sent();
if (err_1 instanceof index_1.ZodError) {
if (err_1 instanceof ZodError_1.ZodError) {
return [2, { success: false, error: err_1 }];

@@ -167,4 +125,4 @@ }

this.refine = function (check, message) {
if (message === void 0) { message = 'Invalid value.'; }
if (typeof message === 'string') {
if (message === void 0) { message = "Invalid value."; }
if (typeof message === "string") {
return _this._refinement(function (val, ctx) {

@@ -174,3 +132,3 @@ var result = check(val);

return ctx.addIssue({
code: index_1.ZodIssueCode.custom,
code: ZodError_1.ZodIssueCode.custom,
message: message,

@@ -191,7 +149,7 @@ });

}
if (typeof message === 'function') {
if (typeof message === "function") {
return _this._refinement(function (val, ctx) {
var result = check(val);
var setError = function () {
return ctx.addIssue(__assign({ code: index_1.ZodIssueCode.custom }, message(val)));
return ctx.addIssue(__assign({ code: ZodError_1.ZodIssueCode.custom }, message(val)));
};

@@ -213,3 +171,3 @@ if (result instanceof Promise) {

var setError = function () {
return ctx.addIssue(__assign({ code: index_1.ZodIssueCode.custom }, message));
return ctx.addIssue(__assign({ code: ZodError_1.ZodIssueCode.custom }, message));
};

@@ -231,3 +189,3 @@ if (result instanceof Promise) {

if (!check(val)) {
ctx.addIssue(typeof refinementData === 'function'
ctx.addIssue(typeof refinementData === "function"
? refinementData(val, ctx)

@@ -277,3 +235,3 @@ : refinementData);

}
return index_1.ZodTransformer.create(this, exports.outputSchema(this), input);
return index_1.ZodTransformer.create(this, this, input);
};

@@ -284,3 +242,3 @@ ZodType.prototype.default = function (def) {

return x === undefined
? typeof def === 'function'
? typeof def === "function"
? def(_this)

@@ -287,0 +245,0 @@ : def

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

import * as z from './base';
export interface ZodBigIntDef extends z.ZodTypeDef {
t: z.ZodTypes.bigint;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodBigIntDef extends ZodTypeDef {
t: ZodTypes.bigint;
}
export declare class ZodBigInt extends z.ZodType<bigint, ZodBigIntDef> {
export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef> {
toJSON: () => ZodBigIntDef;
static create: () => ZodBigInt;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodBigInt = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodBigInt = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodBigInt, _super);

return new ZodBigInt({
t: z.ZodTypes.bigint,
t: ZodTypes_1.ZodTypes.bigint,
});
};
return ZodBigInt;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodBigInt = ZodBigInt;
//# sourceMappingURL=bigint.js.map

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

import * as z from './base';
export interface ZodBooleanDef extends z.ZodTypeDef {
t: z.ZodTypes.boolean;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodBooleanDef extends ZodTypeDef {
t: ZodTypes.boolean;
}
export declare class ZodBoolean extends z.ZodType<boolean, ZodBooleanDef> {
export declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef> {
toJSON: () => ZodBooleanDef;
static create: () => ZodBoolean;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodBoolean = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodBoolean = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodBoolean, _super);

return new ZodBoolean({
t: z.ZodTypes.boolean,
t: ZodTypes_1.ZodTypes.boolean,
});
};
return ZodBoolean;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodBoolean = ZodBoolean;
//# sourceMappingURL=boolean.js.map

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

import * as z from './base';
export interface ZodDateDef extends z.ZodTypeDef {
t: z.ZodTypes.date;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodDateDef extends ZodTypeDef {
t: ZodTypes.date;
}
export declare class ZodDate extends z.ZodType<Date, ZodDateDef> {
export declare class ZodDate extends ZodType<Date, ZodDateDef> {
toJSON: () => ZodDateDef;
static create: () => ZodDate;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodDate = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodDate = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodDate, _super);

return new ZodDate({
t: z.ZodTypes.date,
t: ZodTypes_1.ZodTypes.date,
});
};
return ZodDate;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodDate = ZodDate;
//# sourceMappingURL=date.js.map

@@ -1,2 +0,3 @@

import * as z from './base';
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export declare type ArrayKeys = keyof any[];

@@ -8,7 +9,7 @@ export declare type Indices<T> = Exclude<keyof T, ArrayKeys>;

};
export interface ZodEnumDef<T extends EnumValues = EnumValues> extends z.ZodTypeDef {
t: z.ZodTypes.enum;
export interface ZodEnumDef<T extends EnumValues = EnumValues> extends ZodTypeDef {
t: ZodTypes.enum;
values: T;
}
export declare class ZodEnum<T extends [string, ...string[]]> extends z.ZodType<T[number], ZodEnumDef<T>> {
export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>> {
toJSON: () => ZodEnumDef<T>;

@@ -15,0 +16,0 @@ get options(): T;

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -27,11 +27,6 @@ };

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodEnum = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodEnum = (function (_super) {

@@ -48,3 +43,3 @@ __extends(ZodEnum, _super);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -71,3 +66,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -94,3 +89,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -117,3 +112,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -123,3 +118,3 @@ });

return new ZodEnum({
t: z.ZodTypes.enum,
t: ZodTypes_1.ZodTypes.enum,
values: values,

@@ -129,4 +124,4 @@ });

return ZodEnum;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodEnum = ZodEnum;
//# sourceMappingURL=enum.js.map

@@ -1,22 +0,23 @@

import * as z from './base';
import { ZodTuple } from './tuple';
import { ZodUnknown } from './unknown';
export interface ZodFunctionDef<Args extends ZodTuple<any> = ZodTuple<any>, Returns extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.function;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
import { ZodTuple } from "./tuple";
import { ZodUnknown } from "./unknown";
export interface ZodFunctionDef<Args extends ZodTuple<any> = ZodTuple<any>, Returns extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.function;
args: Args;
returns: Returns;
}
export declare type OuterTypeOfFunction<Args extends ZodTuple<any>, Returns extends z.ZodTypeAny> = Args['_input'] extends Array<any> ? (...args: Args['_input']) => Returns['_output'] : never;
export declare type InnerTypeOfFunction<Args extends ZodTuple<any>, Returns extends z.ZodTypeAny> = Args['_output'] extends Array<any> ? (...args: Args['_output']) => Returns['_input'] : never;
export declare class ZodFunction<Args extends ZodTuple<any>, Returns extends z.ZodTypeAny> extends z.ZodType<OuterTypeOfFunction<Args, Returns>, ZodFunctionDef, InnerTypeOfFunction<Args, Returns>> {
export declare type OuterTypeOfFunction<Args extends ZodTuple<any>, Returns extends ZodTypeAny> = Args["_input"] extends Array<any> ? (...args: Args["_input"]) => Returns["_output"] : never;
export declare type InnerTypeOfFunction<Args extends ZodTuple<any>, Returns extends ZodTypeAny> = Args["_output"] extends Array<any> ? (...args: Args["_output"]) => Returns["_input"] : never;
export declare class ZodFunction<Args extends ZodTuple<any>, Returns extends ZodTypeAny> extends ZodType<OuterTypeOfFunction<Args, Returns>, ZodFunctionDef, InnerTypeOfFunction<Args, Returns>> {
readonly _def: ZodFunctionDef<Args, Returns>;
args: <Items extends [] | [z.ZodTypeAny, ...z.ZodTypeAny[]]>(...items: Items) => ZodFunction<ZodTuple<Items>, Returns>;
returns: <NewReturnType extends z.ZodType<any, any, any>>(returnType: NewReturnType) => ZodFunction<Args, NewReturnType>;
args: <Items extends [ZodTypeAny, ...ZodTypeAny[]] | []>(...items: Items) => ZodFunction<ZodTuple<Items>, Returns>;
returns: <NewReturnType extends ZodType<any, any, any>>(returnType: NewReturnType) => ZodFunction<Args, NewReturnType>;
implement: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => F;
validate: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => F;
static create: <T extends ZodTuple<any> = ZodTuple<[]>, U extends z.ZodTypeAny = ZodUnknown>(args?: T | undefined, returns?: U | undefined) => ZodFunction<T, U>;
static create: <T extends ZodTuple<any> = ZodTuple<[]>, U extends ZodTypeAny = ZodUnknown>(args?: T | undefined, returns?: U | undefined) => ZodFunction<T, U>;
toJSON: () => {
t: z.ZodTypes.function;
t: ZodTypes.function;
args: {
t: z.ZodTypes.tuple;
t: ZodTypes.tuple;
items: any[];

@@ -23,0 +24,0 @@ };

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -27,11 +27,6 @@ };

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodFunction = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var tuple_1 = require("./tuple");

@@ -69,3 +64,3 @@ var unknown_1 = require("./unknown");

return new ZodFunction({
t: z.ZodTypes.function,
t: ZodTypes_1.ZodTypes.function,
args: args || tuple_1.ZodTuple.create([]),

@@ -76,4 +71,4 @@ returns: returns || unknown_1.ZodUnknown.create(),

return ZodFunction;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodFunction = ZodFunction;
//# sourceMappingURL=function.js.map

@@ -1,14 +0,15 @@

import * as z from './base';
export interface ZodIntersectionDef<T extends z.ZodTypeAny = z.ZodTypeAny, U extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.intersection;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.intersection;
left: T;
right: U;
}
export declare class ZodIntersection<T extends z.ZodTypeAny, U extends z.ZodTypeAny> extends z.ZodType<T['_output'] & U['_output'], ZodIntersectionDef<T, U>, T['_input'] & U['_input']> {
export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
toJSON: () => {
t: z.ZodTypes.intersection;
t: ZodTypes.intersection;
left: object;
right: object;
};
static create: <T_1 extends z.ZodTypeAny, U_1 extends z.ZodTypeAny>(left: T_1, right: U_1) => ZodIntersection<T_1, U_1>;
static create: <T_1 extends ZodTypeAny, U_1 extends ZodTypeAny>(left: T_1, right: U_1) => ZodIntersection<T_1, U_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodIntersection = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodIntersection = (function (_super) {

@@ -39,3 +34,3 @@ __extends(ZodIntersection, _super);

return new ZodIntersection({
t: z.ZodTypes.intersection,
t: ZodTypes_1.ZodTypes.intersection,
left: left,

@@ -46,4 +41,4 @@ right: right,

return ZodIntersection;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodIntersection = ZodIntersection;
//# sourceMappingURL=intersection.js.map

@@ -1,10 +0,11 @@

import * as z from './base';
export interface ZodLazyDef<T extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.lazy;
import { ZodTypes } from "../ZodTypes";
import { input, output, ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.lazy;
getter: () => T;
}
export declare class ZodLazy<T extends z.ZodTypeAny> extends z.ZodType<z.output<T>, ZodLazyDef<T>, z.input<T>> {
export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, ZodLazyDef<T>, input<T>> {
get schema(): T;
toJSON: () => never;
static create: <T_1 extends z.ZodTypeAny>(getter: () => T_1) => ZodLazy<T_1>;
static create: <T_1 extends ZodTypeAny>(getter: () => T_1) => ZodLazy<T_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodLazy = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodLazy = (function (_super) {

@@ -39,3 +34,3 @@ __extends(ZodLazy, _super);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -45,3 +40,3 @@ });

return new ZodLazy({
t: z.ZodTypes.lazy,
t: ZodTypes_1.ZodTypes.lazy,
getter: getter,

@@ -51,4 +46,4 @@ });

return ZodLazy;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodLazy = ZodLazy;
//# sourceMappingURL=lazy.js.map

@@ -1,10 +0,10 @@

import * as z from './base';
import { Primitive } from '../helpers/primitive';
export interface ZodLiteralDef<T extends any = any> extends z.ZodTypeDef {
t: z.ZodTypes.literal;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodLiteralDef<T extends any = any> extends ZodTypeDef {
t: ZodTypes.literal;
value: T;
}
export declare class ZodLiteral<T extends any> extends z.ZodType<T, ZodLiteralDef<T>> {
export declare class ZodLiteral<T extends any> extends ZodType<T, ZodLiteralDef<T>> {
toJSON: () => ZodLiteralDef<T>;
static create: <T_1 extends Primitive>(value: T_1) => ZodLiteral<T_1>;
static create: <T_1 extends string | number | bigint | boolean | null | undefined>(value: T_1) => ZodLiteral<T_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodLiteral = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodLiteral = (function (_super) {

@@ -35,3 +30,3 @@ __extends(ZodLiteral, _super);

return new ZodLiteral({
t: z.ZodTypes.literal,
t: ZodTypes_1.ZodTypes.literal,
value: value,

@@ -41,4 +36,4 @@ });

return ZodLiteral;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodLiteral = ZodLiteral;
//# sourceMappingURL=literal.js.map

@@ -1,15 +0,16 @@

import * as z from './base';
export interface ZodMapDef<Key extends z.ZodTypeAny = z.ZodTypeAny, Value extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.map;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodMapDef<Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.map;
valueType: Value;
keyType: Key;
}
export declare class ZodMap<Key extends z.ZodTypeAny = z.ZodTypeAny, Value extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodType<Map<Key['_output'], Value['_output']>, ZodMapDef<Key, Value>, Map<Key['_input'], Value['_input']>> {
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"]>> {
readonly _value: Value;
toJSON: () => {
t: z.ZodTypes.map;
t: ZodTypes.map;
valueType: object;
keyType: object;
};
static create: <Key_1 extends z.ZodTypeAny = z.ZodTypeAny, Value_1 extends z.ZodTypeAny = z.ZodTypeAny>(keyType: Key_1, valueType: Value_1) => ZodMap<Key_1, Value_1>;
static create: <Key_1 extends ZodTypeAny = ZodTypeAny, Value_1 extends ZodTypeAny = ZodTypeAny>(keyType: Key_1, valueType: Value_1) => ZodMap<Key_1, Value_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodMap = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodMap = (function (_super) {

@@ -39,3 +34,3 @@ __extends(ZodMap, _super);

return new ZodMap({
t: z.ZodTypes.map,
t: ZodTypes_1.ZodTypes.map,
valueType: valueType,

@@ -46,4 +41,4 @@ keyType: keyType,

return ZodMap;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodMap = ZodMap;
//# sourceMappingURL=map.js.map

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

import * as z from './base';
export interface ZodNativeEnumDef<T extends EnumLike = EnumLike> extends z.ZodTypeDef {
t: z.ZodTypes.nativeEnum;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodNativeEnumDef<T extends EnumLike = EnumLike> extends ZodTypeDef {
t: ZodTypes.nativeEnum;
values: T;

@@ -10,3 +11,3 @@ }

};
export declare class ZodNativeEnum<T extends EnumLike> extends z.ZodType<T[keyof T], ZodNativeEnumDef<T>> {
export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T], ZodNativeEnumDef<T>> {
toJSON: () => ZodNativeEnumDef<T>;

@@ -13,0 +14,0 @@ static create: <T_1 extends EnumLike>(values: T_1) => ZodNativeEnum<T_1>;

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodNativeEnum = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodNativeEnum = (function (_super) {

@@ -35,3 +30,3 @@ __extends(ZodNativeEnum, _super);

return new ZodNativeEnum({
t: z.ZodTypes.nativeEnum,
t: ZodTypes_1.ZodTypes.nativeEnum,
values: values,

@@ -41,4 +36,4 @@ });

return ZodNativeEnum;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodNativeEnum = ZodNativeEnum;
//# sourceMappingURL=nativeEnum.js.map

@@ -1,8 +0,10 @@

import * as z from './base';
export interface ZodNeverDef extends z.ZodTypeDef {
t: z.ZodTypes.never;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodNeverDef extends ZodTypeDef {
t: ZodTypes.never;
}
export declare class ZodNever extends z.ZodType<never, ZodNeverDef> {
export declare class ZodNever extends ZodType<never, ZodNeverDef> {
__class: string;
toJSON: () => ZodNeverDef;
static create: () => ZodNever;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodNever = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodNever = (function (_super) {

@@ -30,2 +25,3 @@ __extends(ZodNever, _super);

var _this = _super !== null && _super.apply(this, arguments) || this;
_this.__class = "ZodNever";
_this.toJSON = function () { return _this._def; };

@@ -36,8 +32,8 @@ return _this;

return new ZodNever({
t: z.ZodTypes.never,
t: ZodTypes_1.ZodTypes.never,
});
};
return ZodNever;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodNever = ZodNever;
//# sourceMappingURL=never.js.map

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

import * as z from './base';
export interface ZodNullDef extends z.ZodTypeDef {
t: z.ZodTypes.null;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodNullDef extends ZodTypeDef {
t: ZodTypes.null;
}
export declare class ZodNull extends z.ZodType<null, ZodNullDef> {
export declare class ZodNull extends ZodType<null, ZodNullDef> {
toJSON: () => ZodNullDef;
static create: () => ZodNull;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodNull = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodNull = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodNull, _super);

return new ZodNull({
t: z.ZodTypes.null,
t: ZodTypes_1.ZodTypes.null,
});
};
return ZodNull;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodNull = ZodNull;
//# sourceMappingURL=null.js.map

@@ -1,13 +0,14 @@

import * as z from './base';
export interface ZodNullableDef<T extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.nullable;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.nullable;
innerType: T;
}
export declare type ZodNullableType<T extends z.ZodTypeAny> = T extends ZodNullable<z.ZodTypeAny> ? T : ZodNullable<T>;
export declare class ZodNullable<T extends z.ZodTypeAny> extends z.ZodType<T['_output'] | null, ZodNullableDef<T>, T['_input'] | null> {
export declare type ZodNullableType<T extends ZodTypeAny> = T extends ZodNullable<ZodTypeAny> ? T : ZodNullable<T>;
export declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
toJSON: () => {
t: z.ZodTypes.nullable;
t: ZodTypes.nullable;
innerType: object;
};
static create: <T_1 extends z.ZodTypeAny>(type: T_1) => ZodNullableType<T_1>;
static create: <T_1 extends ZodTypeAny>(type: T_1) => ZodNullableType<T_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodNullable = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodNullable = (function (_super) {

@@ -40,3 +35,3 @@ __extends(ZodNullable, _super);

return new ZodNullable({
t: z.ZodTypes.nullable,
t: ZodTypes_1.ZodTypes.nullable,
innerType: type,

@@ -46,4 +41,4 @@ });

return ZodNullable;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodNullable = ZodNullable;
//# sourceMappingURL=nullable.js.map

@@ -1,6 +0,7 @@

import * as z from './base';
export interface ZodNumberDef extends z.ZodTypeDef {
t: z.ZodTypes.number;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodNumberDef extends ZodTypeDef {
t: ZodTypes.number;
}
export declare class ZodNumber extends z.ZodType<number, ZodNumberDef> {
export declare class ZodNumber extends ZodType<number, ZodNumberDef> {
toJSON: () => ZodNumberDef;

@@ -7,0 +8,0 @@ static create: () => ZodNumber;

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -27,13 +27,8 @@ };

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodNumber = void 0;
var errorUtil_1 = require("../helpers/errorUtil");
var ZodError_1 = require("../ZodError");
var errorUtil_1 = require("../helpers/errorUtil");
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodNumber = (function (_super) {

@@ -45,21 +40,21 @@ __extends(ZodNumber, _super);

_this.min = function (minimum, message) {
return _this.refinement(function (data) { return data >= minimum; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: minimum, type: 'number', inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data >= minimum; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: minimum, type: "number", inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.max = function (maximum, message) {
return _this.refinement(function (data) { return data <= maximum; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: maximum, type: 'number', inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data <= maximum; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: maximum, type: "number", inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.int = function (message) {
return _this.refinement(function (data) { return Number.isInteger(data); }, __assign({ code: ZodError_1.ZodIssueCode.invalid_type, expected: 'integer', received: 'number' }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return Number.isInteger(data); }, __assign({ code: ZodError_1.ZodIssueCode.invalid_type, expected: "integer", received: "number" }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.positive = function (message) {
return _this.refinement(function (data) { return data > 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: 0, type: 'number', inclusive: false }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data > 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: 0, type: "number", inclusive: false }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.negative = function (message) {
return _this.refinement(function (data) { return data < 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: 0, type: 'number', inclusive: false }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data < 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: 0, type: "number", inclusive: false }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.nonpositive = function (message) {
return _this.refinement(function (data) { return data <= 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: 0, type: 'number', inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data <= 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: 0, type: "number", inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.nonnegative = function (message) {
return _this.refinement(function (data) { return data >= 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: 0, type: 'number', inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data >= 0; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: 0, type: "number", inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
};

@@ -70,8 +65,8 @@ return _this;

return new ZodNumber({
t: z.ZodTypes.number,
t: ZodTypes_1.ZodTypes.number,
});
};
return ZodNumber;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodNumber = ZodNumber;
//# sourceMappingURL=number.js.map

@@ -1,8 +0,10 @@

import * as z from './base';
import { objectUtil } from '../helpers/objectUtil';
import { partialUtil } from '../helpers/partialUtil';
import { Scalars } from '../helpers/primitive';
declare type UnknownKeysParam = 'passthrough' | 'strict' | 'strip';
export interface ZodObjectDef<T extends z.ZodRawShape = z.ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.object;
import { objectUtil } from "../helpers/objectUtil";
import { partialUtil } from "../helpers/partialUtil";
import { Scalars } from "../helpers/primitive";
import { ZodTypes } from "../ZodTypes";
import { ZodRawShape, ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export declare const mergeObjects: <First extends AnyZodObject>(first: First) => <Second extends AnyZodObject>(second: Second) => ZodObject<First["_shape"] & Second["_shape"], First["_unknownKeys"], First["_catchall"], objectOutputType<First["_shape"] & Second["_shape"], First["_catchall"]>, objectInputType<First["_shape"] & Second["_shape"], First["_catchall"]>>;
declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
export interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.object;
shape: () => T;

@@ -12,16 +14,15 @@ catchall: Catchall;

}
export declare type baseObjectOutputType<Shape extends z.ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]['_output'];
export declare type baseObjectOutputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]["_output"];
}>>;
export declare type objectOutputType<Shape extends z.ZodRawShape, Catchall extends z.ZodTypeAny> = z.ZodTypeAny extends Catchall ? baseObjectOutputType<Shape> : objectUtil.flatten<baseObjectOutputType<Shape> & {
[k: string]: Catchall['_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 z.ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]['_input'];
export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]["_input"];
}>>;
export declare type objectInputType<Shape extends z.ZodRawShape, Catchall extends z.ZodTypeAny> = z.ZodTypeAny extends Catchall ? baseObjectInputType<Shape> : objectUtil.flatten<baseObjectInputType<Shape> & {
[k: string]: Catchall['_input'];
export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? baseObjectInputType<Shape> : objectUtil.flatten<baseObjectInputType<Shape> & {
[k: string]: Catchall["_input"];
}>;
export declare type AnyZodObject = ZodObject<any, any, any>;
export declare class ZodObject<T extends z.ZodRawShape, UnknownKeys extends UnknownKeysParam = 'passthrough', Catchall extends z.ZodTypeAny = z.ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends z.ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = "passthrough", Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
readonly _shape: T;

@@ -32,23 +33,24 @@ readonly _unknownKeys: UnknownKeys;

toJSON: () => {
t: z.ZodTypes.object;
t: ZodTypes.object;
shape: any;
};
strict: () => ZodObject<T, "strict", Catchall, objectOutputType<T, Catchall>, objectInputType<T, Catchall>>;
strip: () => ZodObject<T, "strip", Catchall, objectOutputType<T, Catchall>, objectInputType<T, Catchall>>;
passthrough: () => ZodObject<T, "passthrough", Catchall, objectOutputType<T, Catchall>, objectInputType<T, Catchall>>;
nonstrict: () => ZodObject<T, "passthrough", Catchall, objectOutputType<T, Catchall>, objectInputType<T, Catchall>>;
augment: <Augmentation extends z.ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, UnknownKeys, Catchall, objectOutputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>, objectInputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>>;
extend: <Augmentation extends z.ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, UnknownKeys, Catchall, objectOutputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>, objectInputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>>;
setKey: <Key extends string, Schema extends z.ZodTypeAny>(key: Key, schema: Schema) => ZodObject<T & { [k in Key]: Schema; }, UnknownKeys, Catchall, objectOutputType<T & { [k in Key]: Schema; }, Catchall>, objectInputType<T & { [k in Key]: Schema; }, Catchall>>;
merge: <Incoming extends AnyZodObject>(other: Incoming) => ZodObject<T & Incoming['_shape'], UnknownKeys, Catchall>;
catchall: <Index extends z.ZodTypeAny>(index: Index) => ZodObject<T, UnknownKeys, Index, objectOutputType<T, Index>, objectInputType<T, Index>>;
pick: <Mask extends { [k in keyof T]?: true | undefined; }>(mask: Mask) => ZodObject<{ [k_3 in { [k_2 in keyof { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }]: [{ [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_2]] extends [never] ? never : k_2; }[keyof Mask]]: k_3 extends keyof Mask ? { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_3] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_3 in { [k_2 in keyof { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }]: [{ [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_2]] extends [never] ? never : k_2; }[keyof Mask]]: k_3 extends keyof Mask ? { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_3] : never; }, Catchall>, objectInputType<{ [k_3 in { [k_2 in keyof { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }]: [{ [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_2]] extends [never] ? never : k_2; }[keyof Mask]]: k_3 extends keyof Mask ? { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_3] : never; }, Catchall>>;
omit: <Mask extends { [k in keyof T]?: true | undefined; }>(mask: Mask) => ZodObject<{ [k_3 in { [k_2 in keyof { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }]: [{ [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_2]] extends [never] ? never : k_2; }[keyof T]]: k_3 extends keyof T ? { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_3] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_3 in { [k_2 in keyof { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }]: [{ [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_2]] extends [never] ? never : k_2; }[keyof T]]: k_3 extends keyof T ? { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_3] : never; }, Catchall>, objectInputType<{ [k_3 in { [k_2 in keyof { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }]: [{ [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_2]] extends [never] ? never : k_2; }[keyof T]]: k_3 extends keyof T ? { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_3] : never; }, Catchall>>;
strict: () => ZodObject<T, "strict", Catchall>;
strip: () => ZodObject<T, "strip", Catchall>;
passthrough: () => ZodObject<T, "passthrough", Catchall>;
nonstrict: () => ZodObject<T, "passthrough", Catchall>;
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, UnknownKeys, Catchall, objectOutputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>, objectInputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>>;
extend: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, UnknownKeys, Catchall, objectOutputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>, objectInputType<{ [k in Exclude<keyof T, keyof Augmentation>]: T[k]; } & { [k_1 in keyof Augmentation]: Augmentation[k_1]; }, Catchall>>;
setKey: <Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema) => ZodObject<T & { [k in Key]: Schema; }, UnknownKeys, Catchall, objectOutputType<T & { [k in Key]: Schema; }, Catchall>, objectInputType<T & { [k in Key]: Schema; }, Catchall>>;
merge: <Incoming extends AnyZodObject>(other: Incoming) => ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall>;
catchall: <Index extends ZodTypeAny>(index: Index) => ZodObject<T, UnknownKeys, Index, objectOutputType<T, Index>, objectInputType<T, Index>>;
pick: <Mask extends { [k in keyof T]?: true | undefined; }>(mask: Mask) => ZodObject<{ [k_2 in objectUtil.NoNeverKeys<{ [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }>]: k_2 extends keyof Mask ? { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_2] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_2 in objectUtil.NoNeverKeys<{ [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }>]: k_2 extends keyof Mask ? { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_2] : never; }, Catchall>, objectInputType<{ [k_2 in objectUtil.NoNeverKeys<{ [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }>]: k_2 extends keyof Mask ? { [k_1 in keyof Mask]: k_1 extends keyof T ? T[k_1] : never; }[k_2] : never; }, Catchall>>;
omit: <Mask extends { [k in keyof T]?: true | undefined; }>(mask: Mask) => ZodObject<{ [k_2 in objectUtil.NoNeverKeys<{ [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }>]: k_2 extends keyof T ? { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_2] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_2 in objectUtil.NoNeverKeys<{ [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }>]: k_2 extends keyof T ? { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_2] : never; }, Catchall>, objectInputType<{ [k_2 in objectUtil.NoNeverKeys<{ [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }>]: k_2 extends keyof T ? { [k_1 in keyof T]: k_1 extends keyof Mask ? never : T[k_1]; }[k_2] : never; }, Catchall>>;
partial: () => ZodObject<{ [k in keyof T]: ReturnType<T[k]["optional"]>; }, UnknownKeys, Catchall, objectOutputType<{ [k in keyof T]: ReturnType<T[k]["optional"]>; }, Catchall>, objectInputType<{ [k in keyof T]: ReturnType<T[k]["optional"]>; }, Catchall>>;
primitives: () => ZodObject<{ [k_2 in { [k_1 in keyof { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }]: [{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_1]] extends [never] ? never : k_1; }[keyof T]]: k_2 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_2] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_2 in { [k_1 in keyof { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }]: [{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_1]] extends [never] ? never : k_1; }[keyof T]]: k_2 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_2] : never; }, Catchall>, objectInputType<{ [k_2 in { [k_1 in keyof { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }]: [{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_1]] extends [never] ? never : k_1; }[keyof T]]: k_2 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_2] : never; }, Catchall>>;
nonprimitives: () => ZodObject<{ [k_2 in { [k_1 in keyof { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }]: [{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_1]] extends [never] ? never : k_1; }[keyof T]]: k_2 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_2] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_2 in { [k_1 in keyof { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }]: [{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_1]] extends [never] ? never : k_1; }[keyof T]]: k_2 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_2] : never; }, Catchall>, objectInputType<{ [k_2 in { [k_1 in keyof { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }]: [{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_1]] extends [never] ? never : k_1; }[keyof T]]: k_2 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_2] : never; }, Catchall>>;
primitives: () => ZodObject<{ [k_1 in objectUtil.NoNeverKeys<{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }>]: k_1 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_1] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_1 in objectUtil.NoNeverKeys<{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }>]: k_1 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_1] : never; }, Catchall>, objectInputType<{ [k_1 in objectUtil.NoNeverKeys<{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }>]: k_1 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? T[k] : never; }[k_1] : never; }, Catchall>>;
nonprimitives: () => ZodObject<{ [k_1 in objectUtil.NoNeverKeys<{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }>]: k_1 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_1] : never; }, UnknownKeys, Catchall, objectOutputType<{ [k_1 in objectUtil.NoNeverKeys<{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }>]: k_1 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_1] : never; }, Catchall>, objectInputType<{ [k_1 in objectUtil.NoNeverKeys<{ [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }>]: k_1 extends keyof T ? { [k in keyof T]: [T[k]["_output"]] extends [Scalars] ? never : T[k]; }[k_1] : never; }, Catchall>>;
deepPartial: () => partialUtil.RootDeepPartial<this>;
static create: <T_1 extends z.ZodRawShape>(shape: T_1) => ZodObject<T_1, "passthrough", z.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 z.ZodRawShape>(shape: () => T_1) => ZodObject<T_1, "passthrough", z.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 create: <T_1 extends ZodRawShape>(shape: T_1) => ZodObject<T_1, "passthrough", 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) => ZodObject<T_1, "passthrough", 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]; }>;
}
export declare type AnyZodObject = ZodObject<any, any, any>;
export {};

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -47,14 +47,21 @@ };

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodObject = exports.mergeObjects = void 0;
var objectUtil_1 = require("../helpers/objectUtil");
var isScalar_1 = require("../isScalar");
var __1 = require("..");
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var never_1 = require("./never");
var mergeObjects = function (first) { return function (second) {
var mergedShape = objectUtil_1.objectUtil.mergeShapes(first._def.shape(), second._def.shape());
var merged = new ZodObject({
t: ZodTypes_1.ZodTypes.object,
checks: __spread((first._def.checks || []), (second._def.checks || [])),
unknownKeys: first._def.unknownKeys,
catchall: first._def.catchall,
shape: function () { return mergedShape; },
});
return merged;
}; };
exports.mergeObjects = mergeObjects;
var AugmentFactory = function (def) { return function (augmentation) {

@@ -78,9 +85,9 @@ return new ZodObject(__assign(__assign({}, def), { shape: function () { return (__assign(__assign({}, def.shape()), augmentation)); } }));

_this.strict = function () {
return new ZodObject(__assign(__assign({}, _this._def), { unknownKeys: 'strict' }));
return new ZodObject(__assign(__assign({}, _this._def), { unknownKeys: "strict" }));
};
_this.strip = function () {
return new ZodObject(__assign(__assign({}, _this._def), { unknownKeys: 'strip' }));
return new ZodObject(__assign(__assign({}, _this._def), { unknownKeys: "strip" }));
};
_this.passthrough = function () {
return new ZodObject(__assign(__assign({}, _this._def), { unknownKeys: 'passthrough' }));
return new ZodObject(__assign(__assign({}, _this._def), { unknownKeys: "passthrough" }));
};

@@ -94,3 +101,3 @@ _this.nonstrict = _this.passthrough;

};
_this.merge = objectUtil_1.objectUtil.mergeObjects(_this);
_this.merge = exports.mergeObjects(_this);
_this.catchall = function (index) {

@@ -166,3 +173,3 @@ return new ZodObject(__assign(__assign({}, _this._def), { catchall: index }));

},
enumerable: true,
enumerable: false,
configurable: true

@@ -172,6 +179,6 @@ });

return new ZodObject({
t: z.ZodTypes.object,
t: ZodTypes_1.ZodTypes.object,
shape: function () { return shape; },
unknownKeys: 'strip',
catchall: __1.ZodNever.create(),
unknownKeys: "strip",
catchall: never_1.ZodNever.create(),
});

@@ -181,11 +188,11 @@ };

return new ZodObject({
t: z.ZodTypes.object,
t: ZodTypes_1.ZodTypes.object,
shape: shape,
unknownKeys: 'strip',
catchall: __1.ZodNever.create(),
unknownKeys: "strip",
catchall: never_1.ZodNever.create(),
});
};
return ZodObject;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodObject = ZodObject;
//# sourceMappingURL=object.js.map

@@ -1,2 +0,3 @@

import { ZodType, ZodTypeAny, ZodTypeDef, ZodTypes } from './base';
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {

@@ -7,3 +8,3 @@ t: ZodTypes.optional;

export declare type ZodOptionalType<T extends ZodTypeAny> = T extends ZodOptional<ZodTypeAny> ? T : ZodOptional<T>;
export declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T['_output'] | undefined, ZodOptionalDef<T>, T['_input'] | undefined> {
export declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
toJSON: () => {

@@ -10,0 +11,0 @@ t: ZodTypes.optional;

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -17,2 +17,4 @@ };

Object.defineProperty(exports, "__esModule", { value: true });
exports.ZodOptional = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");

@@ -33,3 +35,3 @@ var ZodOptional = (function (_super) {

return new ZodOptional({
t: base_1.ZodTypes.optional,
t: ZodTypes_1.ZodTypes.optional,
innerType: type,

@@ -36,0 +38,0 @@ });

@@ -1,12 +0,13 @@

import * as z from './base';
export interface ZodPromiseDef<T extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.promise;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.promise;
type: T;
}
export declare class ZodPromise<T extends z.ZodTypeAny> extends z.ZodType<Promise<T['_output']>, ZodPromiseDef<T>, Promise<T['_input']>> {
export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
toJSON: () => {
t: z.ZodTypes.promise;
t: ZodTypes.promise;
type: object;
};
static create: <T_1 extends z.ZodTypeAny>(schema: T_1) => ZodPromise<T_1>;
static create: <T_1 extends ZodTypeAny>(schema: T_1) => ZodPromise<T_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodPromise = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodPromise = (function (_super) {

@@ -40,3 +35,3 @@ __extends(ZodPromise, _super);

return new ZodPromise({
t: z.ZodTypes.promise,
t: ZodTypes_1.ZodTypes.promise,
type: schema,

@@ -46,4 +41,4 @@ });

return ZodPromise;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodPromise = ZodPromise;
//# sourceMappingURL=promise.js.map

@@ -1,13 +0,14 @@

import * as z from './base';
export interface ZodRecordDef<Value extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.record;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodRecordDef<Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.record;
valueType: Value;
}
export declare class ZodRecord<Value extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodType<Record<string, Value['_output']>, ZodRecordDef<Value>, Record<string, Value['_input']>> {
export declare class ZodRecord<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Record<string, Value["_output"]>, ZodRecordDef<Value>, Record<string, Value["_input"]>> {
readonly _value: Value;
toJSON: () => {
t: z.ZodTypes.record;
t: ZodTypes.record;
valueType: object;
};
static create: <Value_1 extends z.ZodTypeAny = z.ZodTypeAny>(valueType: Value_1) => ZodRecord<Value_1>;
static create: <Value_1 extends ZodTypeAny = ZodTypeAny>(valueType: Value_1) => ZodRecord<Value_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodRecord = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodRecord = (function (_super) {

@@ -38,3 +33,3 @@ __extends(ZodRecord, _super);

return new ZodRecord({
t: z.ZodTypes.record,
t: ZodTypes_1.ZodTypes.record,
valueType: valueType,

@@ -44,4 +39,4 @@ });

return ZodRecord;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodRecord = ZodRecord;
//# sourceMappingURL=record.js.map

@@ -1,6 +0,7 @@

import * as z from './base';
import { StringValidation } from '../ZodError';
import { errorUtil } from '../helpers/errorUtil';
export interface ZodStringDef extends z.ZodTypeDef {
t: z.ZodTypes.string;
import { errorUtil } from "../helpers/errorUtil";
import { StringValidation } from "../ZodError";
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodStringDef extends ZodTypeDef {
t: ZodTypes.string;
validation: {

@@ -11,3 +12,3 @@ uuid?: true;

}
export declare class ZodString extends z.ZodType<string, ZodStringDef> {
export declare class ZodString extends ZodType<string, ZodStringDef> {
inputSchema: this;

@@ -14,0 +15,0 @@ outputSchema: this;

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -27,13 +27,8 @@ };

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodString = void 0;
var errorUtil_1 = require("../helpers/errorUtil");
var ZodError_1 = require("../ZodError");
var errorUtil_1 = require("../helpers/errorUtil");
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;

@@ -49,6 +44,6 @@ var uuidRegex = /([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}/i;

_this.min = function (minLength, message) {
return _this.refinement(function (data) { return data.length >= minLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: minLength, type: 'string', inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data.length >= minLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_small, minimum: minLength, type: "string", inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.max = function (maxLength, message) {
return _this.refinement(function (data) { return data.length <= maxLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: maxLength, type: 'string', inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
return _this.refinement(function (data) { return data.length <= maxLength; }, __assign({ code: ZodError_1.ZodIssueCode.too_big, maximum: maxLength, type: "string", inclusive: true }, errorUtil_1.errorUtil.errToObj(message)));
};

@@ -59,3 +54,3 @@ _this._regex = function (regex, validation, message) {

_this.email = function (message) {
return _this._regex(emailRegex, 'email', message);
return _this._regex(emailRegex, "email", message);
};

@@ -71,9 +66,9 @@ _this.url = function (message) {

}
}, __assign({ code: ZodError_1.ZodIssueCode.invalid_string, validation: 'url' }, errorUtil_1.errorUtil.errToObj(message)));
}, __assign({ code: ZodError_1.ZodIssueCode.invalid_string, validation: "url" }, errorUtil_1.errorUtil.errToObj(message)));
};
_this.uuid = function (message) {
return _this._regex(uuidRegex, 'uuid', message);
return _this._regex(uuidRegex, "uuid", message);
};
_this.regex = function (regexp, message) {
return _this._regex(regexp, 'regex', message);
return _this._regex(regexp, "regex", message);
};

@@ -90,3 +85,3 @@ _this.nonempty = function (message) {

return new ZodString({
t: z.ZodTypes.string,
t: ZodTypes_1.ZodTypes.string,
validation: {},

@@ -96,4 +91,4 @@ });

return ZodString;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodString = ZodString;
//# sourceMappingURL=string.js.map

@@ -1,11 +0,12 @@

import * as z from './base';
export interface ZodTransformerDef<T extends z.ZodTypeAny = z.ZodTypeAny, U extends z.ZodTypeAny = z.ZodTypeAny> extends z.ZodTypeDef {
t: z.ZodTypes.transformer;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodTransformerDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
t: ZodTypes.transformer;
input: T;
output: U;
transformer: (arg: T['_output']) => U['_input'];
transformer: (arg: T["_output"]) => U["_input"];
}
export declare class ZodTransformer<T extends z.ZodTypeAny, U extends z.ZodTypeAny> extends z.ZodType<U['_output'], ZodTransformerDef<T, U>, T['_input']> {
export declare class ZodTransformer<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<U["_output"], ZodTransformerDef<T, U>, T["_input"]> {
toJSON: () => {
t: z.ZodTypes.transformer;
t: ZodTypes.transformer;
left: object;

@@ -15,4 +16,4 @@ right: object;

get output(): U;
static create: <I extends z.ZodTypeAny, O extends z.ZodTypeAny>(input: I, output: O, transformer: (arg: I["_output"]) => O["_input"] | Promise<O["_input"]>) => ZodTransformer<I, O>;
static fromSchema: <I extends z.ZodTypeAny>(input: I) => ZodTransformer<I, I>;
static create: <I extends ZodTypeAny, O extends ZodTypeAny>(input: I, output: O, transformer: (arg: I["_output"]) => O["_input"] | Promise<O["_input"]>) => ZodTransformer<I, O>;
static fromSchema: <I extends ZodTypeAny>(input: I) => ZodTransformer<I, I>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodTransformer = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodTransformer = (function (_super) {

@@ -41,3 +36,3 @@ __extends(ZodTransformer, _super);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -47,3 +42,3 @@ });

return new ZodTransformer({
t: z.ZodTypes.transformer,
t: ZodTypes_1.ZodTypes.transformer,
input: input,

@@ -56,3 +51,3 @@ output: output,

return new ZodTransformer({
t: z.ZodTypes.transformer,
t: ZodTypes_1.ZodTypes.transformer,
input: input,

@@ -64,4 +59,4 @@ output: input,

return ZodTransformer;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodTransformer = ZodTransformer;
//# sourceMappingURL=transformer.js.map

@@ -1,19 +0,20 @@

import * as z from './base';
export declare type OutputTypeOfTuple<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]] | []> = {
[k in keyof T]: T[k] extends z.ZodType<any, any> ? T[k]['_output'] : never;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export declare type OutputTypeOfTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | []> = {
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
};
export declare type InputTypeOfTuple<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]] | []> = {
[k in keyof T]: T[k] extends z.ZodType<any, any> ? T[k]['_input'] : never;
export declare type InputTypeOfTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | []> = {
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_input"] : never;
};
export interface ZodTupleDef<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]] | [] = [z.ZodTypeAny, ...z.ZodTypeAny[]]> extends z.ZodTypeDef {
t: z.ZodTypes.tuple;
export interface ZodTupleDef<T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]]> extends ZodTypeDef {
t: ZodTypes.tuple;
items: T;
}
export declare class ZodTuple<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]] | [] = [z.ZodTypeAny, ...z.ZodTypeAny[]]> extends z.ZodType<OutputTypeOfTuple<T>, ZodTupleDef<T>, InputTypeOfTuple<T>> {
export declare class ZodTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]]> extends ZodType<OutputTypeOfTuple<T>, ZodTupleDef<T>, InputTypeOfTuple<T>> {
toJSON: () => {
t: z.ZodTypes.tuple;
t: ZodTypes.tuple;
items: any[];
};
get items(): T;
static create: <T_1 extends [] | [z.ZodTypeAny, ...z.ZodTypeAny[]]>(schemas: T_1) => ZodTuple<T_1>;
static create: <T_1 extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: T_1) => ZodTuple<T_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodTuple = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodTuple = (function (_super) {

@@ -40,3 +35,3 @@ __extends(ZodTuple, _super);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -46,3 +41,3 @@ });

return new ZodTuple({
t: z.ZodTypes.tuple,
t: ZodTypes_1.ZodTypes.tuple,
items: schemas,

@@ -52,4 +47,4 @@ });

return ZodTuple;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodTuple = ZodTuple;
//# sourceMappingURL=tuple.js.map

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

import * as z from './base';
export interface ZodUndefinedDef extends z.ZodTypeDef {
t: z.ZodTypes.undefined;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodUndefinedDef extends ZodTypeDef {
t: ZodTypes.undefined;
}
export declare class ZodUndefined extends z.ZodType<undefined> {
toJSON: () => z.ZodTypeDef;
export declare class ZodUndefined extends ZodType<undefined> {
toJSON: () => ZodTypeDef;
static create: () => ZodUndefined;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodUndefined = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodUndefined = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodUndefined, _super);

return new ZodUndefined({
t: z.ZodTypes.undefined,
t: ZodTypes_1.ZodTypes.undefined,
});
};
return ZodUndefined;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodUndefined = ZodUndefined;
//# sourceMappingURL=undefined.js.map

@@ -1,10 +0,15 @@

import * as z from './base';
export interface ZodUnionDef<T extends [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]] = [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]> extends z.ZodTypeDef {
t: z.ZodTypes.union;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base";
export interface ZodUnionDef<T extends [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]] = [
ZodTypeAny,
ZodTypeAny,
...ZodTypeAny[]
]> extends ZodTypeDef {
t: ZodTypes.union;
options: T;
}
export declare class ZodUnion<T extends [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]> extends z.ZodType<T[number]['_output'], ZodUnionDef<T>, T[number]['_input']> {
export declare class ZodUnion<T extends [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
toJSON: () => object;
get options(): T;
static create: <T_1 extends [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>(types: T_1) => ZodUnion<T_1>;
static create: <T_1 extends [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T_1) => ZodUnion<T_1>;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodUnion = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodUnion = (function (_super) {

@@ -40,3 +35,3 @@ __extends(ZodUnion, _super);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -46,3 +41,3 @@ });

return new ZodUnion({
t: z.ZodTypes.union,
t: ZodTypes_1.ZodTypes.union,
options: types,

@@ -52,4 +47,4 @@ });

return ZodUnion;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodUnion = ZodUnion;
//# sourceMappingURL=union.js.map

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

import * as z from './base';
export interface ZodUnknownDef extends z.ZodTypeDef {
t: z.ZodTypes.unknown;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodUnknownDef extends ZodTypeDef {
t: ZodTypes.unknown;
}
export declare class ZodUnknown extends z.ZodType<unknown, ZodUnknownDef> {
export declare class ZodUnknown extends ZodType<unknown, ZodUnknownDef> {
toJSON: () => ZodUnknownDef;
static create: () => ZodUnknown;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodUnknown = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodUnknown = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodUnknown, _super);

return new ZodUnknown({
t: z.ZodTypes.unknown,
t: ZodTypes_1.ZodTypes.unknown,
});
};
return ZodUnknown;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodUnknown = ZodUnknown;
//# sourceMappingURL=unknown.js.map

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

import * as z from './base';
export interface ZodVoidDef extends z.ZodTypeDef {
t: z.ZodTypes.void;
import { ZodTypes } from "../ZodTypes";
import { ZodType, ZodTypeDef } from "./base";
export interface ZodVoidDef extends ZodTypeDef {
t: ZodTypes.void;
}
export declare class ZodVoid extends z.ZodType<void, ZodVoidDef> {
export declare class ZodVoid extends ZodType<void, ZodVoidDef> {
toJSON: () => ZodVoidDef;
static create: () => ZodVoid;
}

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -16,11 +16,6 @@ };

})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var z = __importStar(require("./base"));
exports.ZodVoid = void 0;
var ZodTypes_1 = require("../ZodTypes");
var base_1 = require("./base");
var ZodVoid = (function (_super) {

@@ -35,8 +30,8 @@ __extends(ZodVoid, _super);

return new ZodVoid({
t: z.ZodTypes.void,
t: ZodTypes_1.ZodTypes.void,
});
};
return ZodVoid;
}(z.ZodType));
}(base_1.ZodType));
exports.ZodVoid = ZodVoid;
//# sourceMappingURL=void.js.map

@@ -1,2 +0,3 @@

import { ZodParsedType } from './parser';
import { util } from "./helpers/util";
import { ZodParsedType } from "./ZodParsedType";
export declare const ZodIssueCode: {

@@ -58,3 +59,3 @@ invalid_type: "invalid_type";

}
export declare type StringValidation = 'email' | 'url' | 'uuid' | 'regex';
export declare type StringValidation = "email" | "url" | "uuid" | "regex";
export interface ZodInvalidStringIssue extends ZodIssueBase {

@@ -68,3 +69,3 @@ code: typeof ZodIssueCode.invalid_string;

inclusive: boolean;
type: 'array' | 'string' | 'number';
type: "array" | "string" | "number";
}

@@ -75,3 +76,3 @@ export interface ZodTooBigIssue extends ZodIssueBase {

inclusive: boolean;
type: 'array' | 'string' | 'number';
type: "array" | "string" | "number";
}

@@ -114,1 +115,6 @@ export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {

}
declare type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
export declare type MakeErrorData = stripPath<ZodIssueOptionalMessage> & {
path?: (string | number)[];
};
export {};

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

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -48,23 +48,25 @@ };

Object.defineProperty(exports, "__esModule", { value: true });
exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
var util_1 = require("./helpers/util");
exports.ZodIssueCode = util_1.util.arrayToEnum([
'invalid_type',
'nonempty_array_is_empty',
'custom',
'invalid_union',
'invalid_literal_value',
'invalid_enum_value',
'unrecognized_keys',
'invalid_arguments',
'invalid_return_type',
'invalid_date',
'invalid_string',
'too_small',
'too_big',
'invalid_intersection_types',
"invalid_type",
"nonempty_array_is_empty",
"custom",
"invalid_union",
"invalid_literal_value",
"invalid_enum_value",
"unrecognized_keys",
"invalid_arguments",
"invalid_return_type",
"invalid_date",
"invalid_string",
"too_small",
"too_big",
"invalid_intersection_types",
]);
exports.quotelessJson = function (obj) {
var quotelessJson = function (obj) {
var json = JSON.stringify(obj, null, 2);
return json.replace(/"([^"]+)":/g, '$1:');
return json.replace(/"([^"]+)":/g, "$1:");
};
exports.quotelessJson = quotelessJson;
var ZodError = (function (_super) {

@@ -117,3 +119,3 @@ __extends(ZodError, _super);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -125,3 +127,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -133,3 +135,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -141,3 +143,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -144,0 +146,0 @@ });

{
"name": "zod",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"description": "TypeScript-first schema declaration and validation library with static type inference",

@@ -22,2 +22,7 @@ "main": "./lib/cjs/index.js",

"funding": "https://github.com/sponsors/colinhacks",
"support": {
"backing": {
"npm-funding": true
}
},
"keywords": [

@@ -31,2 +36,5 @@ "typescript",

"scripts": {
"fix:format": "prettier --write \"src/**/*.ts\"",
"fix:lint": "eslint --fix --ext .ts ./src",
"fix": "yarn fix:lint && yarn fix:format",
"clean": "rm -rf lib/*",

@@ -36,7 +44,5 @@ "build": "yarn run clean && tsc --p tsconfig.cjs.json",

"buildallv2": "yarn add typescript@3.7 && yarn build && yarn add typescript@3.8 && yarn build && yarn add typescript@3.9 && yarn build && yarn add typescript@4.0 && yarn build && yarn add typescript@4.1 && yarn build && yarn add typescript@3.7",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "tslint -p tsconfig.json",
"test": "jest --coverage && yarn run badge",
"testone": "jest",
"badge": "make-coverage-badge --report-path ./coverage/coverage-summary.json --output-path ./coverage.svg",
"badge": "make-coverage-badge --output-path ./coverage.svg",
"prepublishOnly": "npm run build",

@@ -47,2 +53,10 @@ "play": "nodemon -e ts -w . -x ts-node src/playground.ts --project tsconfig.json"

"@types/jest": "^26.0.17",
"@types/node": "^14.14.10",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"dependency-cruiser": "^9.19.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-simple-import-sort": "^6.0.1",
"husky": "^4.3.4",

@@ -53,7 +67,5 @@ "jest": "^26.6.3",

"nodemon": "^2.0.2",
"prettier": "^1.19.1",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"ts-node": "^9.1.0",
"tslint": "^6.1.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "3.8"

@@ -68,5 +80,6 @@ },

"*.ts": [
"prettier --write"
"yarn fix:lint",
"yarn fix:format"
]
}
}

@@ -21,37 +21,26 @@ <p align="center">

### **Sept 17 — Zod 2 is now in beta!**
### ⚠️ Zod 2 is being retired (3 Jan 2020)
You should be able to upgrade from v1 to v2 without any breaking changes to your code. Zod 2 is recommended for all new projects.
⚠️ It's recommended that all v2 users upgrade to v3. ⚠️
```
- Zod v2 was released in beta back in September. Since then we've uncovered some archictectural issues with transformers that result in complicated and unintuitive behavior; these issues are documented in detail [here](https://github.com/colinhacks/zod/issues/264).
- Because of this, Zod v2 will _not be leaving beta_. Instead it is being "retired" and the beta of v3 is being released. After an appropriate beta period, a stable v3 will be released.
- There are breaking changes in v3.
- The syntax for transformers has been changed
- The minimum TypeScript version is now _4.1_
- Type guards have been removed
npm install zod@beta
yarn add zod@beta
```
For a more detailed migration guide, go to the [v3 docs](https://github.com/colinhacks/zod/tree/v3)
Here are some of the new features.
#### Migration from v1
_In almost all cases, you'll be able to upgrade to Zod 2 without changing any code._ Here are the breaking changes + new features:
- Transformers! These let you provide default values, do casting/coercion, and a lot more. Read more here: [Transformers](#transformers)
- Asynchronous refinements and new `.parseAsync` and `.safeParseAsync` methods. Read more here: [Refinements](#refinements)
- Schema parsing now returns a deep clone of the data you pass in (instead of the _exact_ value you pass in)
- Object schemas now strip unknown keys by default. There are also new object methods: `.passthrough()`, `.strict()`, and `.catchall()`. Read more here: [Objects](#objects)
- \[breaking\] Object schemas now strip unknown keys by default. There are also new object methods: `.passthrough()`, `.strict()`, and `.catchall()`. Read more here: [Objects](#objects)
- \[breaking\] Schema parsing now returns a deep clone of the data you pass in (instead of the _exact_ value you pass in)
- \[breaking\] Relatedly, Zod _no longer_ supports cyclical _data_. Recursive schemas are still supported, but Zod can't properly parse nested objects that contain cycles.
- \[breaking\] Optional and nullable schemas are now represented with the dedicated ZodOptional and ZodNullable classes, instead of using ZodUnion.
In almost all cases, you'll be able to upgrade to Zod 2 without changing any code. Here are some of the (very minor) breaking changes:
- Parsing now returns a _deep clone_ of the data you pass in. Previously it returned the exact same object you passed in.
- Relatedly, Zod _no longer_ supports cyclical _data_. Recursive schemas are still supported, but Zod can't properly parse nested objects that contain cycles.
- Object schemas now strip unknown keys by default, instead of throwing an error
- Optional and nullable schemas are now represented with the dedicated ZodOptional and ZodNullable classes, instead of using ZodUnion.
---
Aug 30 — zod@1.11 was released with lots of cool features!
- All schemas now have a `.safeParse` method. This lets you validate data in a more functional way, similar to `io-ts`: https://github.com/colinhacks/zod#safe-parse
- String schemas have a new `.regex` refinement method: https://github.com/colinhacks/zod#strings
- Object schemas now have two new methods: `.primitives()` and `.nonprimitives()`. These methods let you quickly pick or omit primitive fields from objects, useful for validating API inputs: https://github.com/colinhacks/zod#primitives-and-nonprimitives
- Zod now provides `z.nativeEnum()`, which lets you create z Zod schema from an existing TypeScript `enum`: https://github.com/colinhacks/zod#native-enums
<!-- > ⚠️ You might be encountering issues building your project if you're using zod@<1.10.2. This is the result of a bug in the TypeScript compiler. To solve this without updating, set `"skipLibCheck": true` in your tsconfig.json "compilerOptions". This issue is resolved in zod@1.10.2 and later. -->
# What is Zod

@@ -221,3 +210,3 @@

```ts
import * as z from 'zod';
import * as z from "zod";

@@ -244,3 +233,3 @@ // primitive values

```ts
const tuna = z.literal('tuna');
const tuna = z.literal("tuna");
const twelve = z.literal(12);

@@ -266,3 +255,3 @@ const tru = z.literal(true);

const stringSchema = z.string();
stringSchema.parse('fish'); // => returns "fish"
stringSchema.parse("fish"); // => returns "fish"
stringSchema.parse(12); // throws Error('Non-string type: number');

@@ -281,3 +270,3 @@ ```

stringSchema.safeParse('billie');
stringSchema.safeParse("billie");
// => { success: true; data: 'billie' }

@@ -289,3 +278,3 @@ ```

```ts
await stringSchema.safeParseAsync('billie');
await stringSchema.safeParseAsync("billie");
```

@@ -298,3 +287,3 @@

```ts
const result = stringSchema.safeParse('billie');
const result = stringSchema.safeParse("billie");
if (!result.success) {

@@ -320,3 +309,3 @@ // handle error then return

const stringSchema = z.string();
const blob: any = 'Albuquerque';
const blob: any = "Albuquerque";
if (stringSchema.check(blob)) {

@@ -335,3 +324,3 @@ // blob is now of type `string`

if (!stringSchema.check(blob)) {
throw new Error('Not a string');
throw new Error("Not a string");
}

@@ -357,3 +346,3 @@

```ts
const myString = z.string().refine(val => val.length <= 255, {
const myString = z.string().refine((val) => val.length <= 255, {
message: "String can't be more than 255 characters",

@@ -366,3 +355,3 @@ });

```ts
const userId = z.string().refine(async id => {
const userId = z.string().refine(async (id) => {
// verify that ID exists in database

@@ -402,7 +391,7 @@ return true;

})
.refine(data => data.password === data.confirm, {
.refine((data) => data.password === data.confirm, {
message: "Passwords don't match",
path: ['confirm'], // path of error
path: ["confirm"], // path of error
})
.parse({ password: 'asdf', confirm: 'qwer' });
.parse({ password: "asdf", confirm: "qwer" });
```

@@ -429,4 +418,4 @@

passwordForm: {
password: 'asdf',
confirm: 'qwer',
password: "asdf",
confirm: "qwer",
},

@@ -458,3 +447,3 @@ });

const u: A = 12; // TypeError
const u: A = 'asdf'; // compiles
const u: A = "asdf"; // compiles
```

@@ -490,8 +479,8 @@

```ts
z.string().min(5, { message: 'Must be 5 or more characters long' });
z.string().max(5, { message: 'Must be 5 or fewer characters long' });
z.string().length(5, { message: 'Must be exactly 5 characters long' });
z.string().email({ message: 'Invalid email address.' });
z.string().url({ message: 'Invalid url' });
z.string().uuid({ message: 'Invalid UUID' });
z.string().min(5, { message: "Must be 5 or more characters long" });
z.string().max(5, { message: "Must be 5 or fewer characters long" });
z.string().length(5, { message: "Must be exactly 5 characters long" });
z.string().email({ message: "Invalid email address." });
z.string().url({ message: "Invalid url" });
z.string().uuid({ message: "Invalid UUID" });
```

@@ -520,3 +509,3 @@

```ts
z.number().max(5, { message: 'this👏is👏too👏big' });
z.number().max(5, { message: "this👏is👏too👏big" });
```

@@ -543,3 +532,3 @@

const cujo = dogSchema.parse({
name: 'Cujo',
name: "Cujo",
age: 4,

@@ -549,3 +538,3 @@ }); // passes, returns Dog

const fido: Dog = {
name: 'Fido',
name: "Fido",
}; // TypeError: missing required property `age`

@@ -587,5 +576,3 @@ ```

// chaining mixins
const Teacher = BaseTeacher.merge(HasId)
.merge(HasName)
.merge(HasAddress);
const Teacher = BaseTeacher.merge(HasId).merge(HasName).merge(HasAddress);
```

@@ -743,3 +730,3 @@

person.parse({
name: 'bob dylan',
name: "bob dylan",
extraKey: 61,

@@ -764,3 +751,3 @@ });

person.parse({
name: 'bob dylan',
name: "bob dylan",
extraKey: 61,

@@ -783,3 +770,3 @@ });

person.parse({
name: 'bob dylan',
name: "bob dylan",
extraKey: 61,

@@ -838,6 +825,6 @@ });

person.parse({
name: 'bob dylan',
name: "bob dylan",
validExtraKey: 61, // works fine
});
// => { name: "bob dylan" }
// => { name: "bob dylan", validExtraKey: 61 }
```

@@ -894,8 +881,8 @@

userStore['77d2586b-9e8e-4ecf-8b21-ea7e0530eadd'] = {
name: 'Carlotta',
userStore["77d2586b-9e8e-4ecf-8b21-ea7e0530eadd"] = {
name: "Carlotta",
}; // passes
userStore['77d2586b-9e8e-4ecf-8b21-ea7e0530eadd'] = {
whatever: 'Ice cream sundae',
userStore["77d2586b-9e8e-4ecf-8b21-ea7e0530eadd"] = {
whatever: "Ice cream sundae",
}; // TypeError

@@ -908,3 +895,3 @@ ```

UserStore.parse({
user_1328741234: { name: 'James' },
user_1328741234: { name: "James" },
}); // => passes

@@ -921,3 +908,3 @@ ```

const testMap: { [k: number]: string } = {
1: 'one',
1: "one",
};

@@ -960,8 +947,4 @@

```ts
z.string()
.undefined()
.array(); // (string | undefined)[]
z.string()
.array()
.undefined(); // string[] | undefined
z.string().undefined().array(); // (string | undefined)[]
z.string().array().undefined(); // string[] | undefined
```

@@ -980,10 +963,7 @@

```ts
const nonEmptyStrings = z
.string()
.array()
.nonempty();
const nonEmptyStrings = z.string().array().nonempty();
// [string, ...string[]]
nonEmptyStrings.parse([]); // throws: "Array cannot be empty"
nonEmptyStrings.parse(['Ariana Grande']); // passes
nonEmptyStrings.parse(["Ariana Grande"]); // passes
```

@@ -1011,3 +991,3 @@

stringOrNumber.parse('foo'); // passes
stringOrNumber.parse("foo"); // passes
stringOrNumber.parse(14); // passes

@@ -1060,7 +1040,7 @@ ```

const D = z.nullable(z.string());
D.parse('asdf'); // => "asdf"
D.parse("asdf"); // => "asdf"
D.parse(null); // => null
```
Or you can use the `.optional()` method on any existing schema:
Or you can use the `.nullable()` method on any existing schema:

@@ -1104,9 +1084,9 @@ ```ts

const FishEnum = z.union([
z.literal('Salmon'),
z.literal('Tuna'),
z.literal('Trout'),
z.literal("Salmon"),
z.literal("Tuna"),
z.literal("Trout"),
]);
FishEnum.parse('Salmon'); // => "Salmon"
FishEnum.parse('Flounder'); // => throws
FishEnum.parse("Salmon"); // => "Salmon"
FishEnum.parse("Flounder"); // => throws
```

@@ -1117,3 +1097,3 @@

```ts
const FishEnum = z.enum(['Salmon', 'Tuna', 'Trout']);
const FishEnum = z.enum(["Salmon", "Tuna", "Trout"]);

@@ -1177,4 +1157,4 @@ type FishEnum = z.infer<typeof FishEnum>;

enum Fruits {
Apple = 'apple',
Banana = 'banana',
Apple = "apple",
Banana = "banana",
Cantaloupe, // you can mix numerical and string enums

@@ -1188,6 +1168,6 @@ }

FruitEnum.parse(Fruits.Cantaloupe); // passes
FruitEnum.parse('apple'); // passes
FruitEnum.parse('banana'); // passes
FruitEnum.parse("apple"); // passes
FruitEnum.parse("banana"); // passes
FruitEnum.parse(0); // passes
FruitEnum.parse('Cantaloupe'); // fails
FruitEnum.parse("Cantaloupe"); // fails
```

@@ -1201,4 +1181,4 @@

const Fruits = {
Apple: 'apple',
Banana: 'banana',
Apple: "apple",
Banana: "banana",
Cantaloupe: 3,

@@ -1210,6 +1190,6 @@ } as const;

FruitEnum.parse('apple'); // passes
FruitEnum.parse('banana'); // passes
FruitEnum.parse("apple"); // passes
FruitEnum.parse("banana"); // passes
FruitEnum.parse(3); // passes
FruitEnum.parse('Cantaloupe'); // fails
FruitEnum.parse("Cantaloupe"); // fails
```

@@ -1285,11 +1265,11 @@

subcategories: z.array(Category),
}),
})
);
Category.parse({
name: 'People',
name: "People",
subcategories: [
{
name: 'Politicians',
subcategories: [{ name: 'Presidents', subcategories: [] }],
name: "Politicians",
subcategories: [{ name: "Presidents", subcategories: [] }],
},

@@ -1322,3 +1302,3 @@ ],

subcategories: z.lazy(() => z.array(Category)),
}),
})
);

@@ -1336,3 +1316,3 @@ ```

const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]),
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
);

@@ -1379,10 +1359,10 @@

```ts
numberPromise.parse('tuna');
numberPromise.parse("tuna");
// ZodError: Non-Promise type: string
numberPromise.parse(Promise.resolve('tuna'));
numberPromise.parse(Promise.resolve("tuna"));
// => Promise<number>
const test = async () => {
await numberPromise.parse(Promise.resolve('tuna'));
await numberPromise.parse(Promise.resolve("tuna"));
// ZodError: Non-number type: string

@@ -1419,3 +1399,3 @@

const blob: any = 'whatever';
const blob: any = "whatever";
if (TestSchema.check(blob)) {

@@ -1476,3 +1456,3 @@ blob.name; // Test instance

.returns(z.number())
.implement(x => {
.implement((x) => {
// TypeScript knows x is a string!

@@ -1482,7 +1462,7 @@ return x.trim().length;

trimmedLength('sandwich'); // => 8
trimmedLength(' asdf '); // => 4
trimmedLength("sandwich"); // => 8
trimmedLength(" asdf "); // => 4
```
`myValidatedFunction` now automatically validates both its inputs and return value against the schemas provided to `z.function` . If either is invalid, the function throws. This way you can confidently write application logic in a "validated function" without worrying about invalid inputs, scattering `schema.validate()` calls in your endpoint definitions, or writing duplicative types for your functions.
`trimmedLength` now automatically validates both its inputs and return value against the schemas provided to `z.function` . If either is invalid, the function throws. This way you can confidently write application logic in a "validated function" without worrying about invalid inputs, scattering `schema.validate()` calls in your endpoint definitions, or writing duplicative types for your functions.

@@ -1500,7 +1480,7 @@ Here's a more complex example showing how to write a typesafe API query endpoint:

name: string(),
}),
),
})
)
);
const getUserByID = FetcherEndpoint.validate(args => {
const getUserByID = FetcherEndpoint.validate(async (args) => {
args; // => { id: string }

@@ -1512,3 +1492,3 @@

// this function is of type Promise<{ id: string; name: string; }>
return 'salmon'; // TypeError
return "salmon"; // TypeError

@@ -1524,3 +1504,3 @@ return user; // compiles successfully

server.get(`/user/:id`, async (req, res) => {
const user = await getUserByID({ id: req.params.id }).catch(err => {
const user = await getUserByID({ id: req.params.id }).catch((err) => {
res.status(400).send(err.message);

@@ -1618,6 +1598,6 @@ });

z.number(),
myString => myString.length,
(myString) => myString.length
);
countLength.parse('string'); // => 6
countLength.parse("string"); // => 6
```

@@ -1628,3 +1608,3 @@

```ts
const coercedString = z.transformer(z.unknown(), z.string(), val => {
const coercedString = z.transformer(z.unknown(), z.string(), (val) => {
return `${val}`;

@@ -1643,5 +1623,5 @@ });

UserSchema,
userId => async id => {
(userId) => async (id) => {
return await getUserById(id);
},
}
);

@@ -1657,8 +1637,8 @@ ```

```ts
const lengthChecker = z.string().transform(z.boolean(), val => {
const lengthChecker = z.string().transform(z.boolean(), (val) => {
return val.length > 5;
});
lengthChecker.parse('asdf'); // => false;
lengthChecker.parse('qwerty'); // => true;
lengthChecker.parse("asdf"); // => false;
lengthChecker.parse("qwerty"); // => true;
```

@@ -1670,6 +1650,6 @@

z.string()
.transform(val => val.replace('pretty', 'extremely'))
.transform(val => val.toUpperCase())
.transform(val => val.split(' ').join('👏'))
.parse('zod 2 is pretty cool');
.transform((val) => val.replace("pretty", "extremely"))
.transform((val) => val.toUpperCase())
.transform((val) => val.split(" ").join("👏"))
.parse("zod 2 is pretty cool");

@@ -1687,3 +1667,3 @@ // => "ZOD👏2👏IS👏EXTREMELY👏COOL"

z.string(),
val => val || 'default value',
(val) => val || "default value"
);

@@ -1695,3 +1675,3 @@ ```

```ts
z.string().default('default value');
z.string().default("default value");
```

@@ -1786,3 +1766,3 @@

Yup is a full-featured library that was implemented first in vanilla JS, with TypeScript typings added later.
Yup is a full-featured library that was implemented first in vanilla JS, and later rewritten in TypeScript.

@@ -1793,5 +1773,4 @@ Differences

- All object fields are optional by default
- Non-standard `.required()`¹
- Missing object methods: (pick, omit, partial, deepPartial, merge, extend)
- Missing nonempty arrays with proper typing (`[T, ...T[]]`)
- Missing object methods: (partial, deepPartial)
<!-- - Missing nonempty arrays with proper typing (`[T, ...T[]]`) -->
- Missing promise schemas

@@ -1801,3 +1780,3 @@ - Missing function schemas

¹ Yup has a strange interpretation of the word `required` . Instead of meaning "not undefined", Yup uses it to mean "not empty". So `yup.string().required()` will not accept an empty string, and `yup.array(yup.string()).required()` will not accept an empty array. For Zod arrays there is a dedicated `.nonempty()` method to indicate this, or you can implement it with a custom refinement.
<!-- ¹Yup has a strange interpretation of the word `required`. Instead of meaning "not undefined", Yup uses it to mean "not empty". So `yup.string().required()` will not accept an empty string, and `yup.array(yup.string()).required()` will not accept an empty array. Instead, Yup us Zod arrays there is a dedicated `.nonempty()` method to indicate this, or you can implement it with a custom refinement. -->

@@ -1813,3 +1792,3 @@ #### io-ts

```ts
import * as t from 'io-ts';
import * as t from "io-ts";

@@ -1816,0 +1795,0 @@ const A = t.type({

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc