zod 3.25.41 → 3.25.42-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/v4/classic/external.js +1 -1
- package/dist/cjs/v4/classic/schemas.js +3 -3
- package/dist/cjs/v4/core/index.js +1 -2
- package/dist/cjs/v4/core/to-json-schema.js +7 -7
- package/dist/cjs/v4/locales/en.js +2 -4
- package/dist/cjs/v4/mini/external.js +1 -1
- package/dist/cjs/v4/mini/schemas.js +4 -3
- package/dist/esm/v4/classic/external.js +2 -1
- package/dist/esm/v4/classic/schemas.js +2 -3
- package/dist/esm/v4/core/index.js +0 -1
- package/dist/esm/v4/core/to-json-schema.js +7 -7
- package/dist/esm/v4/locales/en.js +2 -2
- package/dist/esm/v4/locales/es.js +1 -1
- package/dist/esm/v4/mini/external.js +2 -1
- package/dist/esm/v4/mini/schemas.js +3 -3
- package/dist/types/v4/classic/external.d.ts +2 -1
- package/dist/types/v4/core/index.d.ts +0 -1
- package/dist/types/v4/locales/en.d.ts +0 -3
- package/dist/types/v4/mini/external.d.ts +2 -1
- package/package.json +1 -1
|
@@ -55,7 +55,7 @@ Object.defineProperty(exports, "prettifyError", { enumerable: true, get: functio
|
|
|
55
55
|
Object.defineProperty(exports, "formatError", { enumerable: true, get: function () { return core_2.formatError; } });
|
|
56
56
|
Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return core_2.flattenError; } });
|
|
57
57
|
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return core_2.toJSONSchema; } });
|
|
58
|
-
|
|
58
|
+
exports.locales = __importStar(require("../locales/index.js"));
|
|
59
59
|
// iso
|
|
60
60
|
// must be exported from top-level
|
|
61
61
|
// https://github.com/colinhacks/zod/issues/4491
|
|
@@ -1081,12 +1081,12 @@ function _instanceof(cls, params = {
|
|
|
1081
1081
|
return inst;
|
|
1082
1082
|
}
|
|
1083
1083
|
// stringbool
|
|
1084
|
-
|
|
1085
|
-
/*@__PURE__*/ core._stringbool.bind(null, {
|
|
1084
|
+
const stringbool = (...args) => core._stringbool({
|
|
1086
1085
|
Pipe: exports.ZodPipe,
|
|
1087
1086
|
Boolean: exports.ZodBoolean,
|
|
1088
1087
|
Unknown: exports.ZodUnknown,
|
|
1089
|
-
});
|
|
1088
|
+
}, ...args);
|
|
1089
|
+
exports.stringbool = stringbool;
|
|
1090
1090
|
function json(params) {
|
|
1091
1091
|
const jsonSchema = lazy(() => {
|
|
1092
1092
|
return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.JSONSchema = exports.
|
|
29
|
+
exports.JSONSchema = exports.regexes = exports.util = void 0;
|
|
30
30
|
__exportStar(require("./core.js"), exports);
|
|
31
31
|
__exportStar(require("./parse.js"), exports);
|
|
32
32
|
__exportStar(require("./errors.js"), exports);
|
|
@@ -35,7 +35,6 @@ __exportStar(require("./checks.js"), exports);
|
|
|
35
35
|
__exportStar(require("./versions.js"), exports);
|
|
36
36
|
exports.util = __importStar(require("./util.js"));
|
|
37
37
|
exports.regexes = __importStar(require("./regexes.js"));
|
|
38
|
-
exports.locales = __importStar(require("../locales/index.js"));
|
|
39
38
|
__exportStar(require("./registries.js"), exports);
|
|
40
39
|
__exportStar(require("./doc.js"), exports);
|
|
41
40
|
__exportStar(require("./function.js"), exports);
|
|
@@ -3,13 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JSONSchemaGenerator = void 0;
|
|
4
4
|
exports.toJSONSchema = toJSONSchema;
|
|
5
5
|
const registries_js_1 = require("./registries.js");
|
|
6
|
-
const formatMap = {
|
|
7
|
-
guid: "uuid",
|
|
8
|
-
url: "uri",
|
|
9
|
-
datetime: "date-time",
|
|
10
|
-
json_string: "json-string",
|
|
11
|
-
regex: "", // do not set
|
|
12
|
-
};
|
|
13
6
|
class JSONSchemaGenerator {
|
|
14
7
|
constructor(params) {
|
|
15
8
|
this.counter = 0;
|
|
@@ -23,6 +16,13 @@ class JSONSchemaGenerator {
|
|
|
23
16
|
process(schema, _params = { path: [], schemaPath: [] }) {
|
|
24
17
|
var _a;
|
|
25
18
|
const def = schema._zod.def;
|
|
19
|
+
const formatMap = {
|
|
20
|
+
guid: "uuid",
|
|
21
|
+
url: "uri",
|
|
22
|
+
datetime: "date-time",
|
|
23
|
+
json_string: "json-string",
|
|
24
|
+
regex: "", // do not set
|
|
25
|
+
};
|
|
26
26
|
// check for schema in seens
|
|
27
27
|
const seen = this.seen.get(schema);
|
|
28
28
|
if (seen) {
|
|
@@ -23,7 +23,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.error = exports.parsedType = void 0;
|
|
27
26
|
exports.default = default_1;
|
|
28
27
|
const util = __importStar(require("../core/util.js"));
|
|
29
28
|
const Sizable = {
|
|
@@ -55,7 +54,6 @@ const parsedType = (data) => {
|
|
|
55
54
|
}
|
|
56
55
|
return t;
|
|
57
56
|
};
|
|
58
|
-
exports.parsedType = parsedType;
|
|
59
57
|
const Nouns = {
|
|
60
58
|
regex: "input",
|
|
61
59
|
email: "email address",
|
|
@@ -89,7 +87,7 @@ const Nouns = {
|
|
|
89
87
|
const error = (issue) => {
|
|
90
88
|
switch (issue.code) {
|
|
91
89
|
case "invalid_type":
|
|
92
|
-
return `Invalid input: expected ${issue.expected}, received ${
|
|
90
|
+
return `Invalid input: expected ${issue.expected}, received ${parsedType(issue.input)}`;
|
|
93
91
|
case "invalid_value":
|
|
94
92
|
if (issue.values.length === 1)
|
|
95
93
|
return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`;
|
|
@@ -136,7 +134,7 @@ const error = (issue) => {
|
|
|
136
134
|
return `Invalid input`;
|
|
137
135
|
}
|
|
138
136
|
};
|
|
139
|
-
|
|
137
|
+
// export { error };
|
|
140
138
|
function default_1() {
|
|
141
139
|
return {
|
|
142
140
|
localeError: error,
|
|
@@ -46,7 +46,7 @@ Object.defineProperty(exports, "prettifyError", { enumerable: true, get: functio
|
|
|
46
46
|
Object.defineProperty(exports, "formatError", { enumerable: true, get: function () { return core_1.formatError; } });
|
|
47
47
|
Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return core_1.flattenError; } });
|
|
48
48
|
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return core_1.toJSONSchema; } });
|
|
49
|
-
|
|
49
|
+
exports.locales = __importStar(require("../locales/index.js"));
|
|
50
50
|
/** A special constant with type `never` */
|
|
51
51
|
// export const NEVER = {} as never;
|
|
52
52
|
// iso
|
|
@@ -114,7 +114,7 @@ const core_1 = require("zod/v4/core");
|
|
|
114
114
|
const parse = __importStar(require("./parse.js"));
|
|
115
115
|
exports.ZodMiniType = core.$constructor("ZodMiniType", (inst, def) => {
|
|
116
116
|
if (!inst._zod)
|
|
117
|
-
throw new Error("Uninitialized schema in
|
|
117
|
+
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
118
118
|
core.$ZodType.init(inst, def);
|
|
119
119
|
inst.def = def;
|
|
120
120
|
inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
|
|
@@ -827,11 +827,12 @@ function _instanceof(cls, params = {
|
|
|
827
827
|
return inst;
|
|
828
828
|
}
|
|
829
829
|
// stringbool
|
|
830
|
-
|
|
830
|
+
const stringbool = (...args) => core._stringbool({
|
|
831
831
|
Pipe: exports.ZodMiniPipe,
|
|
832
832
|
Boolean: exports.ZodMiniBoolean,
|
|
833
833
|
Unknown: exports.ZodMiniUnknown,
|
|
834
|
-
});
|
|
834
|
+
}, ...args);
|
|
835
|
+
exports.stringbool = stringbool;
|
|
835
836
|
function json() {
|
|
836
837
|
const jsonSchema = _lazy(() => {
|
|
837
838
|
return union([string(), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
@@ -8,7 +8,8 @@ export * from "./compat.js";
|
|
|
8
8
|
import { config } from "zod/v4/core";
|
|
9
9
|
import en from "zod/v4/locales/en.js";
|
|
10
10
|
config(en());
|
|
11
|
-
export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema,
|
|
11
|
+
export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, } from "zod/v4/core";
|
|
12
|
+
export * as locales from "../locales/index.js";
|
|
12
13
|
// iso
|
|
13
14
|
// must be exported from top-level
|
|
14
15
|
// https://github.com/colinhacks/zod/issues/4491
|
|
@@ -980,12 +980,11 @@ function _instanceof(cls, params = {
|
|
|
980
980
|
}
|
|
981
981
|
export { _instanceof as instanceof };
|
|
982
982
|
// stringbool
|
|
983
|
-
export const stringbool =
|
|
984
|
-
/*@__PURE__*/ core._stringbool.bind(null, {
|
|
983
|
+
export const stringbool = (...args) => core._stringbool({
|
|
985
984
|
Pipe: ZodPipe,
|
|
986
985
|
Boolean: ZodBoolean,
|
|
987
986
|
Unknown: ZodUnknown,
|
|
988
|
-
});
|
|
987
|
+
}, ...args);
|
|
989
988
|
export function json(params) {
|
|
990
989
|
const jsonSchema = lazy(() => {
|
|
991
990
|
return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
@@ -6,7 +6,6 @@ export * from "./checks.js";
|
|
|
6
6
|
export * from "./versions.js";
|
|
7
7
|
export * as util from "./util.js";
|
|
8
8
|
export * as regexes from "./regexes.js";
|
|
9
|
-
export * as locales from "../locales/index.js";
|
|
10
9
|
export * from "./registries.js";
|
|
11
10
|
export * from "./doc.js";
|
|
12
11
|
export * from "./function.js";
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { $ZodRegistry, globalRegistry } from "./registries.js";
|
|
2
|
-
const formatMap = {
|
|
3
|
-
guid: "uuid",
|
|
4
|
-
url: "uri",
|
|
5
|
-
datetime: "date-time",
|
|
6
|
-
json_string: "json-string",
|
|
7
|
-
regex: "", // do not set
|
|
8
|
-
};
|
|
9
2
|
export class JSONSchemaGenerator {
|
|
10
3
|
constructor(params) {
|
|
11
4
|
this.counter = 0;
|
|
@@ -19,6 +12,13 @@ export class JSONSchemaGenerator {
|
|
|
19
12
|
process(schema, _params = { path: [], schemaPath: [] }) {
|
|
20
13
|
var _a;
|
|
21
14
|
const def = schema._zod.def;
|
|
15
|
+
const formatMap = {
|
|
16
|
+
guid: "uuid",
|
|
17
|
+
url: "uri",
|
|
18
|
+
datetime: "date-time",
|
|
19
|
+
json_string: "json-string",
|
|
20
|
+
regex: "", // do not set
|
|
21
|
+
};
|
|
22
22
|
// check for schema in seens
|
|
23
23
|
const seen = this.seen.get(schema);
|
|
24
24
|
if (seen) {
|
|
@@ -8,7 +8,7 @@ const Sizable = {
|
|
|
8
8
|
function getSizing(origin) {
|
|
9
9
|
return Sizable[origin] ?? null;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const parsedType = (data) => {
|
|
12
12
|
const t = typeof data;
|
|
13
13
|
switch (t) {
|
|
14
14
|
case "number": {
|
|
@@ -108,7 +108,7 @@ const error = (issue) => {
|
|
|
108
108
|
return `Invalid input`;
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
export { error };
|
|
111
|
+
// export { error };
|
|
112
112
|
export default function () {
|
|
113
113
|
return {
|
|
114
114
|
localeError: error,
|
|
@@ -2,7 +2,8 @@ export * as core from "zod/v4/core";
|
|
|
2
2
|
export * from "./parse.js";
|
|
3
3
|
export * from "./schemas.js";
|
|
4
4
|
export * from "./checks.js";
|
|
5
|
-
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema,
|
|
5
|
+
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, } from "zod/v4/core";
|
|
6
|
+
export * as locales from "../locales/index.js";
|
|
6
7
|
/** A special constant with type `never` */
|
|
7
8
|
// export const NEVER = {} as never;
|
|
8
9
|
// iso
|
|
@@ -3,7 +3,7 @@ import { util } from "zod/v4/core";
|
|
|
3
3
|
import * as parse from "./parse.js";
|
|
4
4
|
export const ZodMiniType = /*@__PURE__*/ core.$constructor("ZodMiniType", (inst, def) => {
|
|
5
5
|
if (!inst._zod)
|
|
6
|
-
throw new Error("Uninitialized schema in
|
|
6
|
+
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
7
7
|
core.$ZodType.init(inst, def);
|
|
8
8
|
inst.def = def;
|
|
9
9
|
inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
|
|
@@ -723,11 +723,11 @@ function _instanceof(cls, params = {
|
|
|
723
723
|
}
|
|
724
724
|
export { _instanceof as instanceof };
|
|
725
725
|
// stringbool
|
|
726
|
-
export const stringbool = /* @__PURE__ */ core._stringbool
|
|
726
|
+
export const stringbool = /* @__PURE__ */ (...args) => core._stringbool({
|
|
727
727
|
Pipe: ZodMiniPipe,
|
|
728
728
|
Boolean: ZodMiniBoolean,
|
|
729
729
|
Unknown: ZodMiniUnknown,
|
|
730
|
-
});
|
|
730
|
+
}, ...args);
|
|
731
731
|
export function json() {
|
|
732
732
|
const jsonSchema = _lazy(() => {
|
|
733
733
|
return union([string(), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
@@ -5,7 +5,8 @@ export * from "./errors.js";
|
|
|
5
5
|
export * from "./parse.js";
|
|
6
6
|
export * from "./compat.js";
|
|
7
7
|
export type { infer, output, input } from "zod/v4/core";
|
|
8
|
-
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema,
|
|
8
|
+
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, } from "zod/v4/core";
|
|
9
|
+
export * as locales from "../locales/index.js";
|
|
9
10
|
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
|
|
10
11
|
export * as iso from "./iso.js";
|
|
11
12
|
export type { ZodCoercedString, ZodCoercedNumber, ZodCoercedBigInt, ZodCoercedBoolean, ZodCoercedDate, } from "./coerce.js";
|
|
@@ -6,7 +6,6 @@ export * from "./checks.js";
|
|
|
6
6
|
export * from "./versions.js";
|
|
7
7
|
export * as util from "./util.js";
|
|
8
8
|
export * as regexes from "./regexes.js";
|
|
9
|
-
export * as locales from "../locales/index.js";
|
|
10
9
|
export * from "./registries.js";
|
|
11
10
|
export * from "./doc.js";
|
|
12
11
|
export * from "./function.js";
|
|
@@ -3,7 +3,8 @@ export * from "./parse.js";
|
|
|
3
3
|
export * from "./schemas.js";
|
|
4
4
|
export * from "./checks.js";
|
|
5
5
|
export type { infer, output, input } from "zod/v4/core";
|
|
6
|
-
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema,
|
|
6
|
+
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, } from "zod/v4/core";
|
|
7
|
+
export * as locales from "../locales/index.js";
|
|
7
8
|
/** A special constant with type `never` */
|
|
8
9
|
export * as iso from "./iso.js";
|
|
9
10
|
export { ZodMiniISODateTime, ZodMiniISODate, ZodMiniISOTime, ZodMiniISODuration, } from "./iso.js";
|
package/package.json
CHANGED