feat(planning): grille hebdomadaire complète avec API et filtres
- Connexion API via proxy Angular (résolution CORS, base path /api) - Import CSS ng-zorro global pour les modales et composants - Filtres Camion/Show câblés sur l'affichage de la grille - Camions affichés via TrucksService (linkés au show du même créneau) - Panneau de détails : spectacles + camions du jour sélectionné - Modale de création de spectacle stylisée avec fond et centrage - Positionnement précis des events à la minute dans leur créneau - Auto-scroll vers l'heure courante au chargement - Ligne "maintenant" sur la colonne du jour actuel - Régénération des services OpenAPI (nouveaux noms de types) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-2
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.slugify = exports.toUpperCase = exports.toLowerCase = exports.trim = exports.normalize = exports.overwrite = exports.mime = exports.property = exports.endsWith = exports.startsWith = exports.includes = exports.uppercase = exports.lowercase = exports.regex = exports.length = exports.minLength = exports.maxLength = exports.size = exports.minSize = exports.maxSize = exports.multipleOf = exports.nonnegative = exports.nonpositive = exports.negative = exports.positive = exports.gte = exports.gt = exports.lte = exports.lt = void 0;
|
||||
exports.toUpperCase = exports.toLowerCase = exports.trim = exports.normalize = exports.overwrite = exports.mime = exports.property = exports.endsWith = exports.startsWith = exports.includes = exports.uppercase = exports.lowercase = exports.regex = exports.length = exports.minLength = exports.maxLength = exports.size = exports.minSize = exports.maxSize = exports.multipleOf = exports.nonnegative = exports.nonpositive = exports.negative = exports.positive = exports.gte = exports.gt = exports.lte = exports.lt = void 0;
|
||||
var index_js_1 = require("../core/index.cjs");
|
||||
Object.defineProperty(exports, "lt", { enumerable: true, get: function () { return index_js_1._lt; } });
|
||||
Object.defineProperty(exports, "lte", { enumerable: true, get: function () { return index_js_1._lte; } });
|
||||
@@ -30,4 +30,3 @@ Object.defineProperty(exports, "normalize", { enumerable: true, get: function ()
|
||||
Object.defineProperty(exports, "trim", { enumerable: true, get: function () { return index_js_1._trim; } });
|
||||
Object.defineProperty(exports, "toLowerCase", { enumerable: true, get: function () { return index_js_1._toLowerCase; } });
|
||||
Object.defineProperty(exports, "toUpperCase", { enumerable: true, get: function () { return index_js_1._toUpperCase; } });
|
||||
Object.defineProperty(exports, "slugify", { enumerable: true, get: function () { return index_js_1._slugify; } });
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, type $RefinementCtx as RefinementCtx, } from "../core/index.cjs";
|
||||
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, } from "../core/index.cjs";
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, type $RefinementCtx as RefinementCtx, } from "../core/index.js";
|
||||
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, } from "../core/index.js";
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, } from "../core/index.js";
|
||||
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, } from "../core/index.js";
|
||||
|
||||
+1
-5
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ZodFirstPartyTypeKind = exports.config = exports.$brand = exports.ZodIssueCode = void 0;
|
||||
exports.config = exports.$brand = exports.ZodIssueCode = void 0;
|
||||
exports.setErrorMap = setErrorMap;
|
||||
exports.getErrorMap = getErrorMap;
|
||||
const core = __importStar(require("../core/index.cjs"));
|
||||
@@ -55,7 +55,3 @@ function setErrorMap(map) {
|
||||
function getErrorMap() {
|
||||
return core.config().customError;
|
||||
}
|
||||
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
||||
var ZodFirstPartyTypeKind;
|
||||
(function (ZodFirstPartyTypeKind) {
|
||||
})(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
|
||||
|
||||
-4
@@ -43,8 +43,4 @@ ZodType as ZodTypeAny,
|
||||
ZodType as ZodSchema,
|
||||
/** @deprecated Use `z.ZodType` */
|
||||
ZodType as Schema, };
|
||||
/** Included for Zod 3 compatibility */
|
||||
export type ZodRawShape = core.$ZodShape;
|
||||
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
||||
export declare enum ZodFirstPartyTypeKind {
|
||||
}
|
||||
|
||||
-4
@@ -43,8 +43,4 @@ ZodType as ZodTypeAny,
|
||||
ZodType as ZodSchema,
|
||||
/** @deprecated Use `z.ZodType` */
|
||||
ZodType as Schema, };
|
||||
/** Included for Zod 3 compatibility */
|
||||
export type ZodRawShape = core.$ZodShape;
|
||||
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
||||
export declare enum ZodFirstPartyTypeKind {
|
||||
}
|
||||
|
||||
-4
@@ -25,7 +25,3 @@ export function setErrorMap(map) {
|
||||
export function getErrorMap() {
|
||||
return core.config().customError;
|
||||
}
|
||||
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
||||
export var ZodFirstPartyTypeKind;
|
||||
(function (ZodFirstPartyTypeKind) {
|
||||
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
||||
|
||||
+2
-9
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ZodRealError = exports.ZodError = void 0;
|
||||
const core = __importStar(require("../core/index.cjs"));
|
||||
const index_js_1 = require("../core/index.cjs");
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const initializer = (inst, issues) => {
|
||||
index_js_1.$ZodError.init(inst, issues);
|
||||
inst.name = "ZodError";
|
||||
@@ -40,17 +39,11 @@ const initializer = (inst, issues) => {
|
||||
// enumerable: false,
|
||||
},
|
||||
addIssue: {
|
||||
value: (issue) => {
|
||||
inst.issues.push(issue);
|
||||
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
||||
},
|
||||
value: (issue) => inst.issues.push(issue),
|
||||
// enumerable: false,
|
||||
},
|
||||
addIssues: {
|
||||
value: (issues) => {
|
||||
inst.issues.push(...issues);
|
||||
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
||||
},
|
||||
value: (issues) => inst.issues.push(...issues),
|
||||
// enumerable: false,
|
||||
},
|
||||
isEmpty: {
|
||||
|
||||
+2
-9
@@ -1,6 +1,5 @@
|
||||
import * as core from "../core/index.js";
|
||||
import { $ZodError } from "../core/index.js";
|
||||
import * as util from "../core/util.js";
|
||||
const initializer = (inst, issues) => {
|
||||
$ZodError.init(inst, issues);
|
||||
inst.name = "ZodError";
|
||||
@@ -14,17 +13,11 @@ const initializer = (inst, issues) => {
|
||||
// enumerable: false,
|
||||
},
|
||||
addIssue: {
|
||||
value: (issue) => {
|
||||
inst.issues.push(issue);
|
||||
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
||||
},
|
||||
value: (issue) => inst.issues.push(issue),
|
||||
// enumerable: false,
|
||||
},
|
||||
addIssues: {
|
||||
value: (issues) => {
|
||||
inst.issues.push(...issues);
|
||||
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
||||
},
|
||||
value: (issues) => inst.issues.push(...issues),
|
||||
// enumerable: false,
|
||||
},
|
||||
isEmpty: {
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.NEVER = exports.util = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
||||
exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.NEVER = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.function = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
||||
exports.core = __importStar(require("../core/index.cjs"));
|
||||
__exportStar(require("./schemas.cjs"), exports);
|
||||
__exportStar(require("./checks.cjs"), exports);
|
||||
@@ -44,6 +44,7 @@ var index_js_2 = require("../core/index.cjs");
|
||||
Object.defineProperty(exports, "globalRegistry", { enumerable: true, get: function () { return index_js_2.globalRegistry; } });
|
||||
Object.defineProperty(exports, "registry", { enumerable: true, get: function () { return index_js_2.registry; } });
|
||||
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return index_js_2.config; } });
|
||||
Object.defineProperty(exports, "function", { enumerable: true, get: function () { return index_js_2.function; } });
|
||||
Object.defineProperty(exports, "$output", { enumerable: true, get: function () { return index_js_2.$output; } });
|
||||
Object.defineProperty(exports, "$input", { enumerable: true, get: function () { return index_js_2.$input; } });
|
||||
Object.defineProperty(exports, "$brand", { enumerable: true, get: function () { return index_js_2.$brand; } });
|
||||
@@ -55,7 +56,6 @@ Object.defineProperty(exports, "formatError", { enumerable: true, get: function
|
||||
Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return index_js_2.flattenError; } });
|
||||
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return index_js_2.toJSONSchema; } });
|
||||
Object.defineProperty(exports, "TimePrecision", { enumerable: true, get: function () { return index_js_2.TimePrecision; } });
|
||||
Object.defineProperty(exports, "util", { enumerable: true, get: function () { return index_js_2.util; } });
|
||||
Object.defineProperty(exports, "NEVER", { enumerable: true, get: function () { return index_js_2.NEVER; } });
|
||||
exports.locales = __importStar(require("../locales/index.cjs"));
|
||||
// iso
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ export * from "./errors.cjs";
|
||||
export * from "./parse.cjs";
|
||||
export * from "./compat.cjs";
|
||||
export type { infer, output, input } from "../core/index.cjs";
|
||||
export { globalRegistry, type GlobalMeta, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, util, NEVER, } from "../core/index.cjs";
|
||||
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.cjs";
|
||||
export * as locales from "../locales/index.cjs";
|
||||
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.cjs";
|
||||
export * as iso from "./iso.cjs";
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ export * from "./errors.js";
|
||||
export * from "./parse.js";
|
||||
export * from "./compat.js";
|
||||
export type { infer, output, input } from "../core/index.js";
|
||||
export { globalRegistry, type GlobalMeta, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, util, NEVER, } from "../core/index.js";
|
||||
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
|
||||
export * as locales from "../locales/index.js";
|
||||
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
|
||||
export * as iso from "./iso.js";
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ export * from "./compat.js";
|
||||
import { config } from "../core/index.js";
|
||||
import en from "../locales/en.js";
|
||||
config(en());
|
||||
export { globalRegistry, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, util, NEVER, } from "../core/index.js";
|
||||
export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
|
||||
export * as locales from "../locales/index.js";
|
||||
// iso
|
||||
// must be exported from top-level
|
||||
|
||||
+1
-10
@@ -23,19 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.safeDecodeAsync = exports.safeEncodeAsync = exports.safeDecode = exports.safeEncode = exports.decodeAsync = exports.encodeAsync = exports.decode = exports.encode = exports.safeParseAsync = exports.safeParse = exports.parseAsync = exports.parse = void 0;
|
||||
exports.safeParseAsync = exports.safeParse = exports.parseAsync = exports.parse = void 0;
|
||||
const core = __importStar(require("../core/index.cjs"));
|
||||
const errors_js_1 = require("./errors.cjs");
|
||||
exports.parse = core._parse(errors_js_1.ZodRealError);
|
||||
exports.parseAsync = core._parseAsync(errors_js_1.ZodRealError);
|
||||
exports.safeParse = core._safeParse(errors_js_1.ZodRealError);
|
||||
exports.safeParseAsync = core._safeParseAsync(errors_js_1.ZodRealError);
|
||||
// Codec functions
|
||||
exports.encode = core._encode(errors_js_1.ZodRealError);
|
||||
exports.decode = core._decode(errors_js_1.ZodRealError);
|
||||
exports.encodeAsync = core._encodeAsync(errors_js_1.ZodRealError);
|
||||
exports.decodeAsync = core._decodeAsync(errors_js_1.ZodRealError);
|
||||
exports.safeEncode = core._safeEncode(errors_js_1.ZodRealError);
|
||||
exports.safeDecode = core._safeDecode(errors_js_1.ZodRealError);
|
||||
exports.safeEncodeAsync = core._safeEncodeAsync(errors_js_1.ZodRealError);
|
||||
exports.safeDecodeAsync = core._safeDecodeAsync(errors_js_1.ZodRealError);
|
||||
|
||||
-8
@@ -21,11 +21,3 @@ export declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unk
|
||||
}) => Promise<core.output<T>>;
|
||||
export declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
|
||||
export declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
|
||||
export declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.input<T>;
|
||||
export declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.output<T>;
|
||||
export declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.input<T>>;
|
||||
export declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.output<T>>;
|
||||
export declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.input<T>>;
|
||||
export declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
|
||||
export declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.input<T>>>;
|
||||
export declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
|
||||
|
||||
-8
@@ -21,11 +21,3 @@ export declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unk
|
||||
}) => Promise<core.output<T>>;
|
||||
export declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
|
||||
export declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
|
||||
export declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.input<T>;
|
||||
export declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => core.output<T>;
|
||||
export declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.input<T>>;
|
||||
export declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<core.output<T>>;
|
||||
export declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.input<T>>;
|
||||
export declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => ZodSafeParseResult<core.output<T>>;
|
||||
export declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.input<T>>>;
|
||||
export declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: core.ParseContext<core.$ZodIssue>) => Promise<ZodSafeParseResult<core.output<T>>>;
|
||||
|
||||
-9
@@ -4,12 +4,3 @@ export const parse = /* @__PURE__ */ core._parse(ZodRealError);
|
||||
export const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);
|
||||
export const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);
|
||||
export const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
|
||||
// Codec functions
|
||||
export const encode = /* @__PURE__ */ core._encode(ZodRealError);
|
||||
export const decode = /* @__PURE__ */ core._decode(ZodRealError);
|
||||
export const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);
|
||||
export const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);
|
||||
export const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);
|
||||
export const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
|
||||
export const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
|
||||
export const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
|
||||
|
||||
+49
-104
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodCustomStringFormat = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodMAC = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = void 0;
|
||||
exports.stringbool = exports.meta = exports.describe = exports.ZodCustom = exports.ZodFunction = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodCodec = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransform = void 0;
|
||||
exports.ZodTransform = exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodCustomStringFormat = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = void 0;
|
||||
exports.stringbool = exports.ZodCustom = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = void 0;
|
||||
exports.string = string;
|
||||
exports.email = email;
|
||||
exports.guid = guid;
|
||||
@@ -33,7 +33,6 @@ exports.uuidv4 = uuidv4;
|
||||
exports.uuidv6 = uuidv6;
|
||||
exports.uuidv7 = uuidv7;
|
||||
exports.url = url;
|
||||
exports.httpUrl = httpUrl;
|
||||
exports.emoji = emoji;
|
||||
exports.nanoid = nanoid;
|
||||
exports.cuid = cuid;
|
||||
@@ -42,7 +41,6 @@ exports.ulid = ulid;
|
||||
exports.xid = xid;
|
||||
exports.ksuid = ksuid;
|
||||
exports.ipv4 = ipv4;
|
||||
exports.mac = mac;
|
||||
exports.ipv6 = ipv6;
|
||||
exports.cidrv4 = cidrv4;
|
||||
exports.cidrv6 = cidrv6;
|
||||
@@ -51,9 +49,6 @@ exports.base64url = base64url;
|
||||
exports.e164 = e164;
|
||||
exports.jwt = jwt;
|
||||
exports.stringFormat = stringFormat;
|
||||
exports.hostname = hostname;
|
||||
exports.hex = hex;
|
||||
exports.hash = hash;
|
||||
exports.number = number;
|
||||
exports.int = int;
|
||||
exports.float32 = float32;
|
||||
@@ -100,15 +95,10 @@ exports.success = success;
|
||||
exports.catch = _catch;
|
||||
exports.nan = nan;
|
||||
exports.pipe = pipe;
|
||||
exports.codec = codec;
|
||||
exports.readonly = readonly;
|
||||
exports.templateLiteral = templateLiteral;
|
||||
exports.lazy = lazy;
|
||||
exports.promise = promise;
|
||||
exports._function = _function;
|
||||
exports.function = _function;
|
||||
exports._function = _function;
|
||||
exports.function = _function;
|
||||
exports.check = check;
|
||||
exports.custom = custom;
|
||||
exports.refine = refine;
|
||||
@@ -124,16 +114,18 @@ const parse = __importStar(require("./parse.cjs"));
|
||||
exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
||||
core.$ZodType.init(inst, def);
|
||||
inst.def = def;
|
||||
inst.type = def.type;
|
||||
Object.defineProperty(inst, "_def", { value: def });
|
||||
// base methods
|
||||
inst.check = (...checks) => {
|
||||
return inst.clone(index_js_1.util.mergeDefs(def, {
|
||||
return inst.clone({
|
||||
...def,
|
||||
checks: [
|
||||
...(def.checks ?? []),
|
||||
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
||||
],
|
||||
}));
|
||||
}
|
||||
// { parent: true }
|
||||
);
|
||||
};
|
||||
inst.clone = (def, params) => core.clone(inst, def, params);
|
||||
inst.brand = () => inst;
|
||||
@@ -147,15 +139,6 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
||||
inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
|
||||
inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
|
||||
inst.spa = inst.safeParseAsync;
|
||||
// encoding/decoding
|
||||
inst.encode = (data, params) => parse.encode(inst, data, params);
|
||||
inst.decode = (data, params) => parse.decode(inst, data, params);
|
||||
inst.encodeAsync = async (data, params) => parse.encodeAsync(inst, data, params);
|
||||
inst.decodeAsync = async (data, params) => parse.decodeAsync(inst, data, params);
|
||||
inst.safeEncode = (data, params) => parse.safeEncode(inst, data, params);
|
||||
inst.safeDecode = (data, params) => parse.safeDecode(inst, data, params);
|
||||
inst.safeEncodeAsync = async (data, params) => parse.safeEncodeAsync(inst, data, params);
|
||||
inst.safeDecodeAsync = async (data, params) => parse.safeDecodeAsync(inst, data, params);
|
||||
// refinements
|
||||
inst.refine = (check, params) => inst.check(refine(check, params));
|
||||
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
||||
@@ -224,7 +207,6 @@ exports._ZodString = core.$constructor("_ZodString", (inst, def) => {
|
||||
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
||||
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
||||
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
||||
inst.slugify = () => inst.check(checks.slugify());
|
||||
});
|
||||
exports.ZodString = core.$constructor("ZodString", (inst, def) => {
|
||||
core.$ZodString.init(inst, def);
|
||||
@@ -308,13 +290,6 @@ exports.ZodURL = core.$constructor("ZodURL", (inst, def) => {
|
||||
function url(params) {
|
||||
return core._url(exports.ZodURL, params);
|
||||
}
|
||||
function httpUrl(params) {
|
||||
return core._url(exports.ZodURL, {
|
||||
protocol: /^https?$/,
|
||||
hostname: core.regexes.domain,
|
||||
...index_js_1.util.normalizeParams(params),
|
||||
});
|
||||
}
|
||||
exports.ZodEmoji = core.$constructor("ZodEmoji", (inst, def) => {
|
||||
// ZodStringFormat.init(inst, def);
|
||||
core.$ZodEmoji.init(inst, def);
|
||||
@@ -379,14 +354,6 @@ exports.ZodIPv4 = core.$constructor("ZodIPv4", (inst, def) => {
|
||||
function ipv4(params) {
|
||||
return core._ipv4(exports.ZodIPv4, params);
|
||||
}
|
||||
exports.ZodMAC = core.$constructor("ZodMAC", (inst, def) => {
|
||||
// ZodStringFormat.init(inst, def);
|
||||
core.$ZodMAC.init(inst, def);
|
||||
exports.ZodStringFormat.init(inst, def);
|
||||
});
|
||||
function mac(params) {
|
||||
return core._mac(exports.ZodMAC, params);
|
||||
}
|
||||
exports.ZodIPv6 = core.$constructor("ZodIPv6", (inst, def) => {
|
||||
// ZodStringFormat.init(inst, def);
|
||||
core.$ZodIPv6.init(inst, def);
|
||||
@@ -449,20 +416,6 @@ exports.ZodCustomStringFormat = core.$constructor("ZodCustomStringFormat", (inst
|
||||
function stringFormat(format, fnOrRegex, _params = {}) {
|
||||
return core._stringFormat(exports.ZodCustomStringFormat, format, fnOrRegex, _params);
|
||||
}
|
||||
function hostname(_params) {
|
||||
return core._stringFormat(exports.ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
||||
}
|
||||
function hex(_params) {
|
||||
return core._stringFormat(exports.ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
||||
}
|
||||
function hash(alg, params) {
|
||||
const enc = params?.enc ?? "hex";
|
||||
const format = `${alg}_${enc}`;
|
||||
const regex = core.regexes[format];
|
||||
if (!regex)
|
||||
throw new Error(`Unrecognized hash format: ${format}`);
|
||||
return core._stringFormat(exports.ZodCustomStringFormat, format, regex, params);
|
||||
}
|
||||
exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
|
||||
core.$ZodNumber.init(inst, def);
|
||||
exports.ZodType.init(inst, def);
|
||||
@@ -633,26 +586,22 @@ function array(element, params) {
|
||||
// .keyof
|
||||
function keyof(schema) {
|
||||
const shape = schema._zod.def.shape;
|
||||
return _enum(Object.keys(shape));
|
||||
return literal(Object.keys(shape));
|
||||
}
|
||||
exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
||||
core.$ZodObjectJIT.init(inst, def);
|
||||
core.$ZodObject.init(inst, def);
|
||||
exports.ZodType.init(inst, def);
|
||||
index_js_1.util.defineLazy(inst, "shape", () => {
|
||||
return def.shape;
|
||||
});
|
||||
index_js_1.util.defineLazy(inst, "shape", () => def.shape);
|
||||
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
||||
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
||||
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
||||
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
||||
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
||||
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
||||
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
||||
inst.extend = (incoming) => {
|
||||
return index_js_1.util.extend(inst, incoming);
|
||||
};
|
||||
inst.safeExtend = (incoming) => {
|
||||
return index_js_1.util.safeExtend(inst, incoming);
|
||||
};
|
||||
inst.merge = (other) => index_js_1.util.merge(inst, other);
|
||||
inst.pick = (mask) => index_js_1.util.pick(inst, mask);
|
||||
inst.omit = (mask) => index_js_1.util.omit(inst, mask);
|
||||
@@ -662,7 +611,10 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
||||
function object(shape, params) {
|
||||
const def = {
|
||||
type: "object",
|
||||
shape: shape ?? {},
|
||||
get shape() {
|
||||
index_js_1.util.assignProp(this, "shape", { ...shape });
|
||||
return this.shape;
|
||||
},
|
||||
...index_js_1.util.normalizeParams(params),
|
||||
};
|
||||
return new exports.ZodObject(def);
|
||||
@@ -671,7 +623,10 @@ function object(shape, params) {
|
||||
function strictObject(shape, params) {
|
||||
return new exports.ZodObject({
|
||||
type: "object",
|
||||
shape,
|
||||
get shape() {
|
||||
index_js_1.util.assignProp(this, "shape", { ...shape });
|
||||
return this.shape;
|
||||
},
|
||||
catchall: never(),
|
||||
...index_js_1.util.normalizeParams(params),
|
||||
});
|
||||
@@ -680,7 +635,10 @@ function strictObject(shape, params) {
|
||||
function looseObject(shape, params) {
|
||||
return new exports.ZodObject({
|
||||
type: "object",
|
||||
shape,
|
||||
get shape() {
|
||||
index_js_1.util.assignProp(this, "shape", { ...shape });
|
||||
return this.shape;
|
||||
},
|
||||
catchall: unknown(),
|
||||
...index_js_1.util.normalizeParams(params),
|
||||
});
|
||||
@@ -756,11 +714,9 @@ function record(keyType, valueType, params) {
|
||||
}
|
||||
// type alksjf = core.output<core.$ZodRecordKey>;
|
||||
function partialRecord(keyType, valueType, params) {
|
||||
const k = core.clone(keyType);
|
||||
k._zod.values = undefined;
|
||||
return new exports.ZodRecord({
|
||||
type: "record",
|
||||
keyType: k,
|
||||
keyType: union([keyType, never()]),
|
||||
valueType: valueType,
|
||||
...index_js_1.util.normalizeParams(params),
|
||||
});
|
||||
@@ -889,9 +845,6 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
||||
core.$ZodTransform.init(inst, def);
|
||||
exports.ZodType.init(inst, def);
|
||||
inst._zod.parse = (payload, _ctx) => {
|
||||
if (_ctx.direction === "backward") {
|
||||
throw new core.$ZodEncodeError(inst.constructor.name);
|
||||
}
|
||||
payload.addIssue = (issue) => {
|
||||
if (typeof issue === "string") {
|
||||
payload.issues.push(index_js_1.util.issue(issue, payload.value, def));
|
||||
@@ -904,7 +857,7 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
||||
_issue.code ?? (_issue.code = "custom");
|
||||
_issue.input ?? (_issue.input = payload.value);
|
||||
_issue.inst ?? (_issue.inst = inst);
|
||||
// _issue.continue ??= true;
|
||||
_issue.continue ?? (_issue.continue = true);
|
||||
payload.issues.push(index_js_1.util.issue(_issue));
|
||||
}
|
||||
};
|
||||
@@ -962,7 +915,7 @@ function _default(innerType, defaultValue) {
|
||||
type: "default",
|
||||
innerType: innerType,
|
||||
get defaultValue() {
|
||||
return typeof defaultValue === "function" ? defaultValue() : index_js_1.util.shallowClone(defaultValue);
|
||||
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -976,7 +929,7 @@ function prefault(innerType, defaultValue) {
|
||||
type: "prefault",
|
||||
innerType: innerType,
|
||||
get defaultValue() {
|
||||
return typeof defaultValue === "function" ? defaultValue() : index_js_1.util.shallowClone(defaultValue);
|
||||
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1037,23 +990,9 @@ function pipe(in_, out) {
|
||||
// ...util.normalizeParams(params),
|
||||
});
|
||||
}
|
||||
exports.ZodCodec = core.$constructor("ZodCodec", (inst, def) => {
|
||||
exports.ZodPipe.init(inst, def);
|
||||
core.$ZodCodec.init(inst, def);
|
||||
});
|
||||
function codec(in_, out, params) {
|
||||
return new exports.ZodCodec({
|
||||
type: "pipe",
|
||||
in: in_,
|
||||
out: out,
|
||||
transform: params.decode,
|
||||
reverseTransform: params.encode,
|
||||
});
|
||||
}
|
||||
exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
|
||||
core.$ZodReadonly.init(inst, def);
|
||||
exports.ZodType.init(inst, def);
|
||||
inst.unwrap = () => inst._zod.def.innerType;
|
||||
});
|
||||
function readonly(innerType) {
|
||||
return new exports.ZodReadonly({
|
||||
@@ -1094,17 +1033,6 @@ function promise(innerType) {
|
||||
innerType: innerType,
|
||||
});
|
||||
}
|
||||
exports.ZodFunction = core.$constructor("ZodFunction", (inst, def) => {
|
||||
core.$ZodFunction.init(inst, def);
|
||||
exports.ZodType.init(inst, def);
|
||||
});
|
||||
function _function(params) {
|
||||
return new exports.ZodFunction({
|
||||
type: "function",
|
||||
input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
|
||||
output: params?.output ?? unknown(),
|
||||
});
|
||||
}
|
||||
exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
|
||||
core.$ZodCustom.init(inst, def);
|
||||
exports.ZodType.init(inst, def);
|
||||
@@ -1126,11 +1054,27 @@ function refine(fn, _params = {}) {
|
||||
}
|
||||
// superRefine
|
||||
function superRefine(fn) {
|
||||
return core._superRefine(fn);
|
||||
const ch = check((payload) => {
|
||||
payload.addIssue = (issue) => {
|
||||
if (typeof issue === "string") {
|
||||
payload.issues.push(index_js_1.util.issue(issue, payload.value, ch._zod.def));
|
||||
}
|
||||
else {
|
||||
// for Zod 3 backwards compatibility
|
||||
const _issue = issue;
|
||||
if (_issue.fatal)
|
||||
_issue.continue = false;
|
||||
_issue.code ?? (_issue.code = "custom");
|
||||
_issue.input ?? (_issue.input = payload.value);
|
||||
_issue.inst ?? (_issue.inst = ch);
|
||||
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
||||
payload.issues.push(index_js_1.util.issue(_issue));
|
||||
}
|
||||
};
|
||||
return fn(payload.value, payload);
|
||||
});
|
||||
return ch;
|
||||
}
|
||||
// Re-export describe and meta from core
|
||||
exports.describe = core.describe;
|
||||
exports.meta = core.meta;
|
||||
function _instanceof(cls, params = {
|
||||
error: `Input not instance of ${cls.name}`,
|
||||
}) {
|
||||
@@ -1146,9 +1090,10 @@ function _instanceof(cls, params = {
|
||||
}
|
||||
// stringbool
|
||||
const stringbool = (...args) => core._stringbool({
|
||||
Codec: exports.ZodCodec,
|
||||
Pipe: exports.ZodPipe,
|
||||
Boolean: exports.ZodBoolean,
|
||||
String: exports.ZodString,
|
||||
Transform: exports.ZodTransform,
|
||||
}, ...args);
|
||||
exports.stringbool = stringbool;
|
||||
function json(params) {
|
||||
|
||||
+27
-78
@@ -1,6 +1,9 @@
|
||||
import * as core from "../core/index.cjs";
|
||||
import { util } from "../core/index.cjs";
|
||||
import * as parse from "./parse.cjs";
|
||||
export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
|
||||
addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
|
||||
}
|
||||
export interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
|
||||
def: Internals["def"];
|
||||
type: Internals["def"]["type"];
|
||||
@@ -21,29 +24,22 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
|
||||
parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
|
||||
safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
||||
spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
||||
encode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): core.input<this>;
|
||||
decode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
|
||||
encodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.input<this>>;
|
||||
decodeAsync(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
|
||||
safeEncode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.input<this>>;
|
||||
safeDecode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
|
||||
safeEncodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.input<this>>>;
|
||||
safeDecodeAsync(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
||||
refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
|
||||
superRefine(refinement: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => void | Promise<void>): this;
|
||||
/** @deprecated Use `.check()` instead. */
|
||||
superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
|
||||
overwrite(fn: (x: core.output<this>) => core.output<this>): this;
|
||||
optional(): ZodOptional<this>;
|
||||
nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
|
||||
nullable(): ZodNullable<this>;
|
||||
nullish(): ZodOptional<ZodNullable<this>>;
|
||||
default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
|
||||
default(def: core.output<this>): ZodDefault<this>;
|
||||
default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
|
||||
prefault(def: () => core.input<this>): ZodPrefault<this>;
|
||||
prefault(def: core.input<this>): ZodPrefault<this>;
|
||||
array(): ZodArray<this>;
|
||||
or<T extends core.SomeType>(option: T): ZodUnion<[this, T]>;
|
||||
and<T extends core.SomeType>(incoming: T): ZodIntersection<this, T>;
|
||||
transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
||||
transform<NewOut>(transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
||||
catch(def: core.output<this>): ZodCatch<this>;
|
||||
catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
|
||||
pipe<T extends core.$ZodType<any, core.output<this>>>(target: T | core.$ZodType<any, core.output<this>>): ZodPipe<this, T>;
|
||||
@@ -94,7 +90,6 @@ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$
|
||||
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
||||
toLowerCase(): this;
|
||||
toUpperCase(): this;
|
||||
slugify(): this;
|
||||
}
|
||||
/** @internal */
|
||||
export declare const _ZodString: core.$constructor<_ZodString>;
|
||||
@@ -183,7 +178,6 @@ export interface ZodURL extends ZodStringFormat<"url"> {
|
||||
}
|
||||
export declare const ZodURL: core.$constructor<ZodURL>;
|
||||
export declare function url(params?: string | core.$ZodURLParams): ZodURL;
|
||||
export declare function httpUrl(params?: string | Omit<core.$ZodURLParams, "protocol" | "hostname">): ZodURL;
|
||||
export interface ZodEmoji extends ZodStringFormat<"emoji"> {
|
||||
_zod: core.$ZodEmojiInternals;
|
||||
}
|
||||
@@ -224,11 +218,6 @@ export interface ZodIPv4 extends ZodStringFormat<"ipv4"> {
|
||||
}
|
||||
export declare const ZodIPv4: core.$constructor<ZodIPv4>;
|
||||
export declare function ipv4(params?: string | core.$ZodIPv4Params): ZodIPv4;
|
||||
export interface ZodMAC extends ZodStringFormat<"mac"> {
|
||||
_zod: core.$ZodMACInternals;
|
||||
}
|
||||
export declare const ZodMAC: core.$constructor<ZodMAC>;
|
||||
export declare function mac(params?: string | core.$ZodMACParams): ZodMAC;
|
||||
export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
|
||||
_zod: core.$ZodIPv6Internals;
|
||||
}
|
||||
@@ -269,11 +258,6 @@ export interface ZodCustomStringFormat<Format extends string = string> extends Z
|
||||
}
|
||||
export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
|
||||
export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
|
||||
export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
|
||||
export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
|
||||
export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
|
||||
enc?: Enc;
|
||||
} & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
|
||||
export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals> extends _ZodType<Internals> {
|
||||
gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
|
||||
/** Identical to .min() */
|
||||
@@ -414,10 +398,7 @@ export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodT
|
||||
}
|
||||
export declare const ZodArray: core.$constructor<ZodArray>;
|
||||
export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
|
||||
export declare function keyof<T extends ZodObject>(schema: T): ZodEnum<util.KeysEnum<T["_zod"]["output"]>>;
|
||||
export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
||||
[K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
|
||||
};
|
||||
export declare function keyof<T extends ZodObject>(schema: T): ZodLiteral<Exclude<keyof T["_zod"]["output"], symbol>>;
|
||||
export interface ZodObject<
|
||||
/** @ts-ignore Cast variance */
|
||||
out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
|
||||
@@ -433,10 +414,19 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
||||
strict(): ZodObject<Shape, core.$strict>;
|
||||
/** This is the default behavior. This method call is likely unnecessary. */
|
||||
strip(): ZodObject<Shape, core.$strip>;
|
||||
extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
||||
safeExtend<U extends core.$ZodLooseShape>(shape: SafeExtendShape<Shape, U> & Partial<Record<keyof Shape, core.SomeType>>): ZodObject<util.Extend<Shape, U>, Config>;
|
||||
extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
||||
/**
|
||||
* @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
|
||||
* @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
|
||||
*
|
||||
* ```ts
|
||||
* const A = z.object({ a: z.string() });
|
||||
* const B = z.object({ b: z.number() });
|
||||
*
|
||||
* const C = z.object({
|
||||
* ...A.shape,
|
||||
* ...B.shape
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
|
||||
pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
||||
@@ -463,12 +453,11 @@ export interface ZodUnion<T extends readonly core.SomeType[] = readonly core.$Zo
|
||||
}
|
||||
export declare const ZodUnion: core.$constructor<ZodUnion>;
|
||||
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
||||
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[], Disc extends string = string> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options, Disc> {
|
||||
_zod: core.$ZodDiscriminatedUnionInternals<Options, Disc>;
|
||||
def: core.$ZodDiscriminatedUnionDef<Options, Disc>;
|
||||
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
|
||||
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
||||
}
|
||||
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types, Disc>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
|
||||
export interface ZodIntersection<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodIntersectionInternals<A, B>>, core.$ZodIntersection<A, B> {
|
||||
}
|
||||
export declare const ZodIntersection: core.$constructor<ZodIntersection>;
|
||||
@@ -495,6 +484,7 @@ export declare const ZodMap: core.$constructor<ZodMap>;
|
||||
export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
|
||||
export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
|
||||
min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
|
||||
/** */
|
||||
nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
|
||||
max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
|
||||
size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
|
||||
@@ -591,17 +581,7 @@ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core
|
||||
}
|
||||
export declare const ZodPipe: core.$constructor<ZodPipe>;
|
||||
export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
|
||||
export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends ZodPipe<A, B>, core.$ZodCodec<A, B> {
|
||||
_zod: core.$ZodCodecInternals<A, B>;
|
||||
def: core.$ZodCodecDef<A, B>;
|
||||
}
|
||||
export declare const ZodCodec: core.$constructor<ZodCodec>;
|
||||
export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
|
||||
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
||||
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
||||
}): ZodCodec<A, B>;
|
||||
export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
|
||||
unwrap(): T;
|
||||
}
|
||||
export declare const ZodReadonly: core.$constructor<ZodReadonly>;
|
||||
export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
|
||||
@@ -619,48 +599,17 @@ export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _Zo
|
||||
}
|
||||
export declare const ZodPromise: core.$constructor<ZodPromise>;
|
||||
export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
|
||||
export interface ZodFunction<Args extends core.$ZodFunctionIn = core.$ZodFunctionIn, Returns extends core.$ZodFunctionOut = core.$ZodFunctionOut> extends _ZodType<core.$ZodFunctionInternals<Args, Returns>>, core.$ZodFunction<Args, Returns> {
|
||||
_def: core.$ZodFunctionDef<Args, Returns>;
|
||||
_input: core.$InferInnerFunctionType<Args, Returns>;
|
||||
_output: core.$InferOuterFunctionType<Args, Returns>;
|
||||
input<const Items extends util.TupleItems, const Rest extends core.$ZodFunctionOut = core.$ZodFunctionOut>(args: Items, rest?: Rest): ZodFunction<core.$ZodTuple<Items, Rest>, Returns>;
|
||||
input<NewArgs extends core.$ZodFunctionIn>(args: NewArgs): ZodFunction<NewArgs, Returns>;
|
||||
input(...args: any[]): ZodFunction<any, Returns>;
|
||||
output<NewReturns extends core.$ZodType>(output: NewReturns): ZodFunction<Args, NewReturns>;
|
||||
}
|
||||
export declare const ZodFunction: core.$constructor<ZodFunction>;
|
||||
export declare function _function(): ZodFunction;
|
||||
export declare function _function<const In extends ReadonlyArray<core.$ZodType>>(params: {
|
||||
input: In;
|
||||
}): ZodFunction<ZodTuple<In, null>, core.$ZodFunctionOut>;
|
||||
export declare function _function<const In extends ReadonlyArray<core.$ZodType>, const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
|
||||
input: In;
|
||||
output: Out;
|
||||
}): ZodFunction<ZodTuple<In, null>, Out>;
|
||||
export declare function _function<const In extends core.$ZodFunctionIn = core.$ZodFunctionIn>(params: {
|
||||
input: In;
|
||||
}): ZodFunction<In, core.$ZodFunctionOut>;
|
||||
export declare function _function<const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
|
||||
output: Out;
|
||||
}): ZodFunction<core.$ZodFunctionIn, Out>;
|
||||
export declare function _function<In extends core.$ZodFunctionIn = core.$ZodFunctionIn, Out extends core.$ZodType = core.$ZodType>(params?: {
|
||||
input: In;
|
||||
output: Out;
|
||||
}): ZodFunction<In, Out>;
|
||||
export { _function as function };
|
||||
export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
|
||||
}
|
||||
export declare const ZodCustom: core.$constructor<ZodCustom>;
|
||||
export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
|
||||
export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
|
||||
export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
|
||||
export declare const describe: typeof core.describe;
|
||||
export declare const meta: typeof core.meta;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
|
||||
type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
|
||||
declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
|
||||
export { _instanceof as instanceof };
|
||||
export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
|
||||
export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodPipe<ZodString, ZodTransform<boolean, string>>, ZodBoolean>;
|
||||
type _ZodJSONSchema = ZodUnion<[
|
||||
ZodString,
|
||||
ZodNumber,
|
||||
@@ -678,4 +627,4 @@ export interface ZodJSONSchema extends _ZodJSONSchema {
|
||||
_zod: ZodJSONSchemaInternals;
|
||||
}
|
||||
export declare function json(params?: string | core.$ZodCustomParams): ZodJSONSchema;
|
||||
export declare function preprocess<A, U extends core.SomeType, B = unknown>(fn: (arg: B, ctx: core.$RefinementCtx) => A, schema: U): ZodPipe<ZodTransform<A, B>, U>;
|
||||
export declare function preprocess<A, U extends core.SomeType, B = unknown>(fn: (arg: B, ctx: RefinementCtx) => A, schema: U): ZodPipe<ZodTransform<A, B>, U>;
|
||||
|
||||
+27
-78
@@ -1,6 +1,9 @@
|
||||
import * as core from "../core/index.js";
|
||||
import { util } from "../core/index.js";
|
||||
import * as parse from "./parse.js";
|
||||
export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
|
||||
addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
|
||||
}
|
||||
export interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
|
||||
def: Internals["def"];
|
||||
type: Internals["def"]["type"];
|
||||
@@ -21,29 +24,22 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
|
||||
parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
|
||||
safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
||||
spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
||||
encode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): core.input<this>;
|
||||
decode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
|
||||
encodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.input<this>>;
|
||||
decodeAsync(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
|
||||
safeEncode(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.input<this>>;
|
||||
safeDecode(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
|
||||
safeEncodeAsync(data: core.output<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.input<this>>>;
|
||||
safeDecodeAsync(data: core.input<this>, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
||||
refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
|
||||
superRefine(refinement: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => void | Promise<void>): this;
|
||||
/** @deprecated Use `.check()` instead. */
|
||||
superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
|
||||
overwrite(fn: (x: core.output<this>) => core.output<this>): this;
|
||||
optional(): ZodOptional<this>;
|
||||
nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
|
||||
nullable(): ZodNullable<this>;
|
||||
nullish(): ZodOptional<ZodNullable<this>>;
|
||||
default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
|
||||
default(def: core.output<this>): ZodDefault<this>;
|
||||
default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
|
||||
prefault(def: () => core.input<this>): ZodPrefault<this>;
|
||||
prefault(def: core.input<this>): ZodPrefault<this>;
|
||||
array(): ZodArray<this>;
|
||||
or<T extends core.SomeType>(option: T): ZodUnion<[this, T]>;
|
||||
and<T extends core.SomeType>(incoming: T): ZodIntersection<this, T>;
|
||||
transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
||||
transform<NewOut>(transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
||||
catch(def: core.output<this>): ZodCatch<this>;
|
||||
catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
|
||||
pipe<T extends core.$ZodType<any, core.output<this>>>(target: T | core.$ZodType<any, core.output<this>>): ZodPipe<this, T>;
|
||||
@@ -94,7 +90,6 @@ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$
|
||||
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
||||
toLowerCase(): this;
|
||||
toUpperCase(): this;
|
||||
slugify(): this;
|
||||
}
|
||||
/** @internal */
|
||||
export declare const _ZodString: core.$constructor<_ZodString>;
|
||||
@@ -183,7 +178,6 @@ export interface ZodURL extends ZodStringFormat<"url"> {
|
||||
}
|
||||
export declare const ZodURL: core.$constructor<ZodURL>;
|
||||
export declare function url(params?: string | core.$ZodURLParams): ZodURL;
|
||||
export declare function httpUrl(params?: string | Omit<core.$ZodURLParams, "protocol" | "hostname">): ZodURL;
|
||||
export interface ZodEmoji extends ZodStringFormat<"emoji"> {
|
||||
_zod: core.$ZodEmojiInternals;
|
||||
}
|
||||
@@ -224,11 +218,6 @@ export interface ZodIPv4 extends ZodStringFormat<"ipv4"> {
|
||||
}
|
||||
export declare const ZodIPv4: core.$constructor<ZodIPv4>;
|
||||
export declare function ipv4(params?: string | core.$ZodIPv4Params): ZodIPv4;
|
||||
export interface ZodMAC extends ZodStringFormat<"mac"> {
|
||||
_zod: core.$ZodMACInternals;
|
||||
}
|
||||
export declare const ZodMAC: core.$constructor<ZodMAC>;
|
||||
export declare function mac(params?: string | core.$ZodMACParams): ZodMAC;
|
||||
export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
|
||||
_zod: core.$ZodIPv6Internals;
|
||||
}
|
||||
@@ -269,11 +258,6 @@ export interface ZodCustomStringFormat<Format extends string = string> extends Z
|
||||
}
|
||||
export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat>;
|
||||
export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
|
||||
export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
|
||||
export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
|
||||
export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
|
||||
enc?: Enc;
|
||||
} & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
|
||||
export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals> extends _ZodType<Internals> {
|
||||
gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
|
||||
/** Identical to .min() */
|
||||
@@ -414,10 +398,7 @@ export interface ZodArray<T extends core.SomeType = core.$ZodType> extends _ZodT
|
||||
}
|
||||
export declare const ZodArray: core.$constructor<ZodArray>;
|
||||
export declare function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
|
||||
export declare function keyof<T extends ZodObject>(schema: T): ZodEnum<util.KeysEnum<T["_zod"]["output"]>>;
|
||||
export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
||||
[K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
|
||||
};
|
||||
export declare function keyof<T extends ZodObject>(schema: T): ZodLiteral<Exclude<keyof T["_zod"]["output"], symbol>>;
|
||||
export interface ZodObject<
|
||||
/** @ts-ignore Cast variance */
|
||||
out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _ZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
|
||||
@@ -433,10 +414,19 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
||||
strict(): ZodObject<Shape, core.$strict>;
|
||||
/** This is the default behavior. This method call is likely unnecessary. */
|
||||
strip(): ZodObject<Shape, core.$strip>;
|
||||
extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
||||
safeExtend<U extends core.$ZodLooseShape>(shape: SafeExtendShape<Shape, U> & Partial<Record<keyof Shape, core.SomeType>>): ZodObject<util.Extend<Shape, U>, Config>;
|
||||
extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
||||
/**
|
||||
* @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
|
||||
* @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
|
||||
*
|
||||
* ```ts
|
||||
* const A = z.object({ a: z.string() });
|
||||
* const B = z.object({ b: z.number() });
|
||||
*
|
||||
* const C = z.object({
|
||||
* ...A.shape,
|
||||
* ...B.shape
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
|
||||
pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
||||
@@ -463,12 +453,11 @@ export interface ZodUnion<T extends readonly core.SomeType[] = readonly core.$Zo
|
||||
}
|
||||
export declare const ZodUnion: core.$constructor<ZodUnion>;
|
||||
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
||||
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[], Disc extends string = string> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options, Disc> {
|
||||
_zod: core.$ZodDiscriminatedUnionInternals<Options, Disc>;
|
||||
def: core.$ZodDiscriminatedUnionDef<Options, Disc>;
|
||||
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
|
||||
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
||||
}
|
||||
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types, Disc>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
|
||||
export interface ZodIntersection<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodIntersectionInternals<A, B>>, core.$ZodIntersection<A, B> {
|
||||
}
|
||||
export declare const ZodIntersection: core.$constructor<ZodIntersection>;
|
||||
@@ -495,6 +484,7 @@ export declare const ZodMap: core.$constructor<ZodMap>;
|
||||
export declare function map<Key extends core.SomeType, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodMapParams): ZodMap<Key, Value>;
|
||||
export interface ZodSet<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodSetInternals<T>>, core.$ZodSet<T> {
|
||||
min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
|
||||
/** */
|
||||
nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
|
||||
max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
|
||||
size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
|
||||
@@ -591,17 +581,7 @@ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core
|
||||
}
|
||||
export declare const ZodPipe: core.$constructor<ZodPipe>;
|
||||
export declare function pipe<const A extends core.SomeType, B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>>(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
|
||||
export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType> extends ZodPipe<A, B>, core.$ZodCodec<A, B> {
|
||||
_zod: core.$ZodCodecInternals<A, B>;
|
||||
def: core.$ZodCodecDef<A, B>;
|
||||
}
|
||||
export declare const ZodCodec: core.$constructor<ZodCodec>;
|
||||
export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
|
||||
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
||||
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
||||
}): ZodCodec<A, B>;
|
||||
export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
|
||||
unwrap(): T;
|
||||
}
|
||||
export declare const ZodReadonly: core.$constructor<ZodReadonly>;
|
||||
export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
|
||||
@@ -619,48 +599,17 @@ export interface ZodPromise<T extends core.SomeType = core.$ZodType> extends _Zo
|
||||
}
|
||||
export declare const ZodPromise: core.$constructor<ZodPromise>;
|
||||
export declare function promise<T extends core.SomeType>(innerType: T): ZodPromise<T>;
|
||||
export interface ZodFunction<Args extends core.$ZodFunctionIn = core.$ZodFunctionIn, Returns extends core.$ZodFunctionOut = core.$ZodFunctionOut> extends _ZodType<core.$ZodFunctionInternals<Args, Returns>>, core.$ZodFunction<Args, Returns> {
|
||||
_def: core.$ZodFunctionDef<Args, Returns>;
|
||||
_input: core.$InferInnerFunctionType<Args, Returns>;
|
||||
_output: core.$InferOuterFunctionType<Args, Returns>;
|
||||
input<const Items extends util.TupleItems, const Rest extends core.$ZodFunctionOut = core.$ZodFunctionOut>(args: Items, rest?: Rest): ZodFunction<core.$ZodTuple<Items, Rest>, Returns>;
|
||||
input<NewArgs extends core.$ZodFunctionIn>(args: NewArgs): ZodFunction<NewArgs, Returns>;
|
||||
input(...args: any[]): ZodFunction<any, Returns>;
|
||||
output<NewReturns extends core.$ZodType>(output: NewReturns): ZodFunction<Args, NewReturns>;
|
||||
}
|
||||
export declare const ZodFunction: core.$constructor<ZodFunction>;
|
||||
export declare function _function(): ZodFunction;
|
||||
export declare function _function<const In extends ReadonlyArray<core.$ZodType>>(params: {
|
||||
input: In;
|
||||
}): ZodFunction<ZodTuple<In, null>, core.$ZodFunctionOut>;
|
||||
export declare function _function<const In extends ReadonlyArray<core.$ZodType>, const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
|
||||
input: In;
|
||||
output: Out;
|
||||
}): ZodFunction<ZodTuple<In, null>, Out>;
|
||||
export declare function _function<const In extends core.$ZodFunctionIn = core.$ZodFunctionIn>(params: {
|
||||
input: In;
|
||||
}): ZodFunction<In, core.$ZodFunctionOut>;
|
||||
export declare function _function<const Out extends core.$ZodFunctionOut = core.$ZodFunctionOut>(params: {
|
||||
output: Out;
|
||||
}): ZodFunction<core.$ZodFunctionIn, Out>;
|
||||
export declare function _function<In extends core.$ZodFunctionIn = core.$ZodFunctionIn, Out extends core.$ZodType = core.$ZodType>(params?: {
|
||||
input: In;
|
||||
output: Out;
|
||||
}): ZodFunction<In, Out>;
|
||||
export { _function as function };
|
||||
export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodCustomInternals<O, I>>, core.$ZodCustom<O, I> {
|
||||
}
|
||||
export declare const ZodCustom: core.$constructor<ZodCustom>;
|
||||
export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
|
||||
export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
|
||||
export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
|
||||
export declare const describe: typeof core.describe;
|
||||
export declare const meta: typeof core.meta;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
|
||||
type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
|
||||
declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodCustom<InstanceType<T>, InstanceType<T>>;
|
||||
export { _instanceof as instanceof };
|
||||
export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodCodec<ZodString, ZodBoolean>;
|
||||
export declare const stringbool: (_params?: string | core.$ZodStringBoolParams) => ZodPipe<ZodPipe<ZodString, ZodTransform<boolean, string>>, ZodBoolean>;
|
||||
type _ZodJSONSchema = ZodUnion<[
|
||||
ZodString,
|
||||
ZodNumber,
|
||||
@@ -678,4 +627,4 @@ export interface ZodJSONSchema extends _ZodJSONSchema {
|
||||
_zod: ZodJSONSchemaInternals;
|
||||
}
|
||||
export declare function json(params?: string | core.$ZodCustomParams): ZodJSONSchema;
|
||||
export declare function preprocess<A, U extends core.SomeType, B = unknown>(fn: (arg: B, ctx: core.$RefinementCtx) => A, schema: U): ZodPipe<ZodTransform<A, B>, U>;
|
||||
export declare function preprocess<A, U extends core.SomeType, B = unknown>(fn: (arg: B, ctx: RefinementCtx) => A, schema: U): ZodPipe<ZodTransform<A, B>, U>;
|
||||
|
||||
+47
-93
@@ -6,16 +6,18 @@ import * as parse from "./parse.js";
|
||||
export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
|
||||
core.$ZodType.init(inst, def);
|
||||
inst.def = def;
|
||||
inst.type = def.type;
|
||||
Object.defineProperty(inst, "_def", { value: def });
|
||||
// base methods
|
||||
inst.check = (...checks) => {
|
||||
return inst.clone(util.mergeDefs(def, {
|
||||
return inst.clone({
|
||||
...def,
|
||||
checks: [
|
||||
...(def.checks ?? []),
|
||||
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
||||
],
|
||||
}));
|
||||
}
|
||||
// { parent: true }
|
||||
);
|
||||
};
|
||||
inst.clone = (def, params) => core.clone(inst, def, params);
|
||||
inst.brand = () => inst;
|
||||
@@ -29,15 +31,6 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
||||
inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
|
||||
inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
|
||||
inst.spa = inst.safeParseAsync;
|
||||
// encoding/decoding
|
||||
inst.encode = (data, params) => parse.encode(inst, data, params);
|
||||
inst.decode = (data, params) => parse.decode(inst, data, params);
|
||||
inst.encodeAsync = async (data, params) => parse.encodeAsync(inst, data, params);
|
||||
inst.decodeAsync = async (data, params) => parse.decodeAsync(inst, data, params);
|
||||
inst.safeEncode = (data, params) => parse.safeEncode(inst, data, params);
|
||||
inst.safeDecode = (data, params) => parse.safeDecode(inst, data, params);
|
||||
inst.safeEncodeAsync = async (data, params) => parse.safeEncodeAsync(inst, data, params);
|
||||
inst.safeDecodeAsync = async (data, params) => parse.safeDecodeAsync(inst, data, params);
|
||||
// refinements
|
||||
inst.refine = (check, params) => inst.check(refine(check, params));
|
||||
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
||||
@@ -106,7 +99,6 @@ export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, d
|
||||
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
||||
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
||||
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
||||
inst.slugify = () => inst.check(checks.slugify());
|
||||
});
|
||||
export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
|
||||
core.$ZodString.init(inst, def);
|
||||
@@ -190,13 +182,6 @@ export const ZodURL = /*@__PURE__*/ core.$constructor("ZodURL", (inst, def) => {
|
||||
export function url(params) {
|
||||
return core._url(ZodURL, params);
|
||||
}
|
||||
export function httpUrl(params) {
|
||||
return core._url(ZodURL, {
|
||||
protocol: /^https?$/,
|
||||
hostname: core.regexes.domain,
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
}
|
||||
export const ZodEmoji = /*@__PURE__*/ core.$constructor("ZodEmoji", (inst, def) => {
|
||||
// ZodStringFormat.init(inst, def);
|
||||
core.$ZodEmoji.init(inst, def);
|
||||
@@ -261,14 +246,6 @@ export const ZodIPv4 = /*@__PURE__*/ core.$constructor("ZodIPv4", (inst, def) =>
|
||||
export function ipv4(params) {
|
||||
return core._ipv4(ZodIPv4, params);
|
||||
}
|
||||
export const ZodMAC = /*@__PURE__*/ core.$constructor("ZodMAC", (inst, def) => {
|
||||
// ZodStringFormat.init(inst, def);
|
||||
core.$ZodMAC.init(inst, def);
|
||||
ZodStringFormat.init(inst, def);
|
||||
});
|
||||
export function mac(params) {
|
||||
return core._mac(ZodMAC, params);
|
||||
}
|
||||
export const ZodIPv6 = /*@__PURE__*/ core.$constructor("ZodIPv6", (inst, def) => {
|
||||
// ZodStringFormat.init(inst, def);
|
||||
core.$ZodIPv6.init(inst, def);
|
||||
@@ -331,20 +308,6 @@ export const ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("ZodCustomS
|
||||
export function stringFormat(format, fnOrRegex, _params = {}) {
|
||||
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
||||
}
|
||||
export function hostname(_params) {
|
||||
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
||||
}
|
||||
export function hex(_params) {
|
||||
return core._stringFormat(ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
||||
}
|
||||
export function hash(alg, params) {
|
||||
const enc = params?.enc ?? "hex";
|
||||
const format = `${alg}_${enc}`;
|
||||
const regex = core.regexes[format];
|
||||
if (!regex)
|
||||
throw new Error(`Unrecognized hash format: ${format}`);
|
||||
return core._stringFormat(ZodCustomStringFormat, format, regex, params);
|
||||
}
|
||||
export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
|
||||
core.$ZodNumber.init(inst, def);
|
||||
ZodType.init(inst, def);
|
||||
@@ -518,26 +481,22 @@ export function array(element, params) {
|
||||
// .keyof
|
||||
export function keyof(schema) {
|
||||
const shape = schema._zod.def.shape;
|
||||
return _enum(Object.keys(shape));
|
||||
return literal(Object.keys(shape));
|
||||
}
|
||||
export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def) => {
|
||||
core.$ZodObjectJIT.init(inst, def);
|
||||
core.$ZodObject.init(inst, def);
|
||||
ZodType.init(inst, def);
|
||||
util.defineLazy(inst, "shape", () => {
|
||||
return def.shape;
|
||||
});
|
||||
util.defineLazy(inst, "shape", () => def.shape);
|
||||
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
||||
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
||||
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
||||
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
||||
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
||||
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
||||
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
||||
inst.extend = (incoming) => {
|
||||
return util.extend(inst, incoming);
|
||||
};
|
||||
inst.safeExtend = (incoming) => {
|
||||
return util.safeExtend(inst, incoming);
|
||||
};
|
||||
inst.merge = (other) => util.merge(inst, other);
|
||||
inst.pick = (mask) => util.pick(inst, mask);
|
||||
inst.omit = (mask) => util.omit(inst, mask);
|
||||
@@ -547,7 +506,10 @@ export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def
|
||||
export function object(shape, params) {
|
||||
const def = {
|
||||
type: "object",
|
||||
shape: shape ?? {},
|
||||
get shape() {
|
||||
util.assignProp(this, "shape", { ...shape });
|
||||
return this.shape;
|
||||
},
|
||||
...util.normalizeParams(params),
|
||||
};
|
||||
return new ZodObject(def);
|
||||
@@ -556,7 +518,10 @@ export function object(shape, params) {
|
||||
export function strictObject(shape, params) {
|
||||
return new ZodObject({
|
||||
type: "object",
|
||||
shape,
|
||||
get shape() {
|
||||
util.assignProp(this, "shape", { ...shape });
|
||||
return this.shape;
|
||||
},
|
||||
catchall: never(),
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
@@ -565,7 +530,10 @@ export function strictObject(shape, params) {
|
||||
export function looseObject(shape, params) {
|
||||
return new ZodObject({
|
||||
type: "object",
|
||||
shape,
|
||||
get shape() {
|
||||
util.assignProp(this, "shape", { ...shape });
|
||||
return this.shape;
|
||||
},
|
||||
catchall: unknown(),
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
@@ -641,11 +609,9 @@ export function record(keyType, valueType, params) {
|
||||
}
|
||||
// type alksjf = core.output<core.$ZodRecordKey>;
|
||||
export function partialRecord(keyType, valueType, params) {
|
||||
const k = core.clone(keyType);
|
||||
k._zod.values = undefined;
|
||||
return new ZodRecord({
|
||||
type: "record",
|
||||
keyType: k,
|
||||
keyType: union([keyType, never()]),
|
||||
valueType: valueType,
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
@@ -775,9 +741,6 @@ export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (ins
|
||||
core.$ZodTransform.init(inst, def);
|
||||
ZodType.init(inst, def);
|
||||
inst._zod.parse = (payload, _ctx) => {
|
||||
if (_ctx.direction === "backward") {
|
||||
throw new core.$ZodEncodeError(inst.constructor.name);
|
||||
}
|
||||
payload.addIssue = (issue) => {
|
||||
if (typeof issue === "string") {
|
||||
payload.issues.push(util.issue(issue, payload.value, def));
|
||||
@@ -790,7 +753,7 @@ export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (ins
|
||||
_issue.code ?? (_issue.code = "custom");
|
||||
_issue.input ?? (_issue.input = payload.value);
|
||||
_issue.inst ?? (_issue.inst = inst);
|
||||
// _issue.continue ??= true;
|
||||
_issue.continue ?? (_issue.continue = true);
|
||||
payload.issues.push(util.issue(_issue));
|
||||
}
|
||||
};
|
||||
@@ -848,7 +811,7 @@ export function _default(innerType, defaultValue) {
|
||||
type: "default",
|
||||
innerType: innerType,
|
||||
get defaultValue() {
|
||||
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
||||
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -862,7 +825,7 @@ export function prefault(innerType, defaultValue) {
|
||||
type: "prefault",
|
||||
innerType: innerType,
|
||||
get defaultValue() {
|
||||
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
||||
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -924,23 +887,9 @@ export function pipe(in_, out) {
|
||||
// ...util.normalizeParams(params),
|
||||
});
|
||||
}
|
||||
export const ZodCodec = /*@__PURE__*/ core.$constructor("ZodCodec", (inst, def) => {
|
||||
ZodPipe.init(inst, def);
|
||||
core.$ZodCodec.init(inst, def);
|
||||
});
|
||||
export function codec(in_, out, params) {
|
||||
return new ZodCodec({
|
||||
type: "pipe",
|
||||
in: in_,
|
||||
out: out,
|
||||
transform: params.decode,
|
||||
reverseTransform: params.encode,
|
||||
});
|
||||
}
|
||||
export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst, def) => {
|
||||
core.$ZodReadonly.init(inst, def);
|
||||
ZodType.init(inst, def);
|
||||
inst.unwrap = () => inst._zod.def.innerType;
|
||||
});
|
||||
export function readonly(innerType) {
|
||||
return new ZodReadonly({
|
||||
@@ -981,18 +930,6 @@ export function promise(innerType) {
|
||||
innerType: innerType,
|
||||
});
|
||||
}
|
||||
export const ZodFunction = /*@__PURE__*/ core.$constructor("ZodFunction", (inst, def) => {
|
||||
core.$ZodFunction.init(inst, def);
|
||||
ZodType.init(inst, def);
|
||||
});
|
||||
export function _function(params) {
|
||||
return new ZodFunction({
|
||||
type: "function",
|
||||
input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
|
||||
output: params?.output ?? unknown(),
|
||||
});
|
||||
}
|
||||
export { _function as function };
|
||||
export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
|
||||
core.$ZodCustom.init(inst, def);
|
||||
ZodType.init(inst, def);
|
||||
@@ -1014,11 +951,27 @@ export function refine(fn, _params = {}) {
|
||||
}
|
||||
// superRefine
|
||||
export function superRefine(fn) {
|
||||
return core._superRefine(fn);
|
||||
const ch = check((payload) => {
|
||||
payload.addIssue = (issue) => {
|
||||
if (typeof issue === "string") {
|
||||
payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
|
||||
}
|
||||
else {
|
||||
// for Zod 3 backwards compatibility
|
||||
const _issue = issue;
|
||||
if (_issue.fatal)
|
||||
_issue.continue = false;
|
||||
_issue.code ?? (_issue.code = "custom");
|
||||
_issue.input ?? (_issue.input = payload.value);
|
||||
_issue.inst ?? (_issue.inst = ch);
|
||||
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
||||
payload.issues.push(util.issue(_issue));
|
||||
}
|
||||
};
|
||||
return fn(payload.value, payload);
|
||||
});
|
||||
return ch;
|
||||
}
|
||||
// Re-export describe and meta from core
|
||||
export const describe = core.describe;
|
||||
export const meta = core.meta;
|
||||
function _instanceof(cls, params = {
|
||||
error: `Input not instance of ${cls.name}`,
|
||||
}) {
|
||||
@@ -1035,9 +988,10 @@ function _instanceof(cls, params = {
|
||||
export { _instanceof as instanceof };
|
||||
// stringbool
|
||||
export const stringbool = (...args) => core._stringbool({
|
||||
Codec: ZodCodec,
|
||||
Pipe: ZodPipe,
|
||||
Boolean: ZodBoolean,
|
||||
String: ZodString,
|
||||
Transform: ZodTransform,
|
||||
}, ...args);
|
||||
export function json(params) {
|
||||
const jsonSchema = lazy(() => {
|
||||
|
||||
Reference in New Issue
Block a user