zod 3.25.71 → 3.25.73
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/index.cjs +2 -2
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/v4/classic/schemas.ts +4 -2
- package/src/v4/classic/tests/brand.test.ts +1 -3
- package/src/v4/classic/tests/discriminated-unions.test.ts +27 -0
- package/src/v4/classic/tests/index.test.ts +1 -1
- package/src/v4/classic/tests/object.test.ts +11 -1
- package/src/v4/classic/tests/optional.test.ts +20 -0
- package/src/v4/classic/tests/record.test.ts +7 -1
- package/src/v4/classic/tests/recursive-types.test.ts +3 -2
- package/src/v4/classic/tests/to-json-schema.test.ts +101 -1
- package/src/v4/core/schemas.ts +52 -18
- package/src/v4/core/to-json-schema.ts +16 -9
- package/src/v4/locales/eo.ts +125 -0
- package/src/v4/locales/index.ts +1 -0
- package/src/v4/mini/schemas.ts +2 -2
- package/src/v4/mini/tests/string.test.ts +6 -0
- package/v4/classic/schemas.cjs +1 -1
- package/v4/classic/schemas.d.cts +2 -1
- package/v4/classic/schemas.d.ts +2 -1
- package/v4/classic/schemas.js +1 -1
- package/v4/core/schemas.cjs +18 -5
- package/v4/core/schemas.d.cts +18 -9
- package/v4/core/schemas.d.ts +18 -9
- package/v4/core/schemas.js +18 -5
- package/v4/core/to-json-schema.cjs +3 -6
- package/v4/core/to-json-schema.d.cts +5 -1
- package/v4/core/to-json-schema.d.ts +5 -1
- package/v4/core/to-json-schema.js +3 -6
- package/v4/locales/eo.cjs +144 -0
- package/v4/locales/eo.d.cts +5 -0
- package/v4/locales/eo.d.ts +5 -0
- package/v4/locales/eo.js +116 -0
- package/v4/locales/index.cjs +3 -1
- package/v4/locales/index.d.cts +1 -0
- package/v4/locales/index.d.ts +1 -0
- package/v4/locales/index.js +1 -0
- package/v4/mini/schemas.cjs +1 -1
- package/v4/mini/schemas.d.cts +1 -1
- package/v4/mini/schemas.d.ts +1 -1
- package/v4/mini/schemas.js +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { $ZodStringFormats } from "../core/checks.js";
|
|
2
|
+
import type * as errors from "../core/errors.js";
|
|
3
|
+
import * as util from "../core/util.js";
|
|
4
|
+
|
|
5
|
+
export const parsedType = (data: any): string => {
|
|
6
|
+
const t = typeof data;
|
|
7
|
+
|
|
8
|
+
switch (t) {
|
|
9
|
+
case "number": {
|
|
10
|
+
return Number.isNaN(data) ? "NaN" : "nombro";
|
|
11
|
+
}
|
|
12
|
+
case "object": {
|
|
13
|
+
if (Array.isArray(data)) {
|
|
14
|
+
return "tabelo";
|
|
15
|
+
}
|
|
16
|
+
if (data === null) {
|
|
17
|
+
return "senvalora";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
21
|
+
return data.constructor.name;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const error: () => errors.$ZodErrorMap = () => {
|
|
29
|
+
const Sizable: Record<string, { unit: string; verb: string }> = {
|
|
30
|
+
string: { unit: "karaktrojn", verb: "havi" },
|
|
31
|
+
file: { unit: "bajtojn", verb: "havi" },
|
|
32
|
+
array: { unit: "elementojn", verb: "havi" },
|
|
33
|
+
set: { unit: "elementojn", verb: "havi" },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function getSizing(origin: string): { unit: string; verb: string } | null {
|
|
37
|
+
return Sizable[origin] ?? null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Nouns: {
|
|
41
|
+
[k in $ZodStringFormats | (string & {})]?: string;
|
|
42
|
+
} = {
|
|
43
|
+
regex: "enigo",
|
|
44
|
+
email: "retadreso",
|
|
45
|
+
url: "URL",
|
|
46
|
+
emoji: "emoĝio",
|
|
47
|
+
uuid: "UUID",
|
|
48
|
+
uuidv4: "UUIDv4",
|
|
49
|
+
uuidv6: "UUIDv6",
|
|
50
|
+
nanoid: "nanoid",
|
|
51
|
+
guid: "GUID",
|
|
52
|
+
cuid: "cuid",
|
|
53
|
+
cuid2: "cuid2",
|
|
54
|
+
ulid: "ULID",
|
|
55
|
+
xid: "XID",
|
|
56
|
+
ksuid: "KSUID",
|
|
57
|
+
datetime: "ISO-datotempo",
|
|
58
|
+
date: "ISO-dato",
|
|
59
|
+
time: "ISO-tempo",
|
|
60
|
+
duration: "ISO-daŭro",
|
|
61
|
+
ipv4: "IPv4-adreso",
|
|
62
|
+
ipv6: "IPv6-adreso",
|
|
63
|
+
cidrv4: "IPv4-rango",
|
|
64
|
+
cidrv6: "IPv6-rango",
|
|
65
|
+
base64: "64-ume kodita karaktraro",
|
|
66
|
+
base64url: "URL-64-ume kodita karaktraro",
|
|
67
|
+
json_string: "JSON-karaktraro",
|
|
68
|
+
e164: "E.164-nombro",
|
|
69
|
+
jwt: "JWT",
|
|
70
|
+
template_literal: "enigo",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (issue) => {
|
|
74
|
+
switch (issue.code) {
|
|
75
|
+
case "invalid_type":
|
|
76
|
+
return `Nevalida enigo: atendiĝis ${issue.expected}, riceviĝis ${parsedType(issue.input)}`;
|
|
77
|
+
|
|
78
|
+
case "invalid_value":
|
|
79
|
+
if (issue.values.length === 1) return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`;
|
|
80
|
+
return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`;
|
|
81
|
+
case "too_big": {
|
|
82
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
83
|
+
const sizing = getSizing(issue.origin);
|
|
84
|
+
if (sizing)
|
|
85
|
+
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`;
|
|
86
|
+
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`;
|
|
87
|
+
}
|
|
88
|
+
case "too_small": {
|
|
89
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
90
|
+
const sizing = getSizing(issue.origin);
|
|
91
|
+
if (sizing) {
|
|
92
|
+
return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`;
|
|
96
|
+
}
|
|
97
|
+
case "invalid_format": {
|
|
98
|
+
const _issue = issue as errors.$ZodStringFormatIssues;
|
|
99
|
+
if (_issue.format === "starts_with") return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`;
|
|
100
|
+
if (_issue.format === "ends_with") return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`;
|
|
101
|
+
if (_issue.format === "includes") return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`;
|
|
102
|
+
if (_issue.format === "regex") return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`;
|
|
103
|
+
return `Nevalida ${Nouns[_issue.format] ?? issue.format}`;
|
|
104
|
+
}
|
|
105
|
+
case "not_multiple_of":
|
|
106
|
+
return `Nevalida nombro: devas esti oblo de ${issue.divisor}`;
|
|
107
|
+
case "unrecognized_keys":
|
|
108
|
+
return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
|
109
|
+
case "invalid_key":
|
|
110
|
+
return `Nevalida ŝlosilo en ${issue.origin}`;
|
|
111
|
+
case "invalid_union":
|
|
112
|
+
return "Nevalida enigo";
|
|
113
|
+
case "invalid_element":
|
|
114
|
+
return `Nevalida valoro en ${issue.origin}`;
|
|
115
|
+
default:
|
|
116
|
+
return `Nevalida enigo`;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default function (): { localeError: errors.$ZodErrorMap } {
|
|
122
|
+
return {
|
|
123
|
+
localeError: error(),
|
|
124
|
+
};
|
|
125
|
+
}
|
package/src/v4/locales/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as ca } from "./ca.js";
|
|
|
5
5
|
export { default as cs } from "./cs.js";
|
|
6
6
|
export { default as de } from "./de.js";
|
|
7
7
|
export { default as en } from "./en.js";
|
|
8
|
+
export { default as eo } from "./eo.js";
|
|
8
9
|
export { default as es } from "./es.js";
|
|
9
10
|
export { default as fa } from "./fa.js";
|
|
10
11
|
export { default as fi } from "./fi.js";
|
package/src/v4/mini/schemas.ts
CHANGED
|
@@ -1023,11 +1023,11 @@ export function partialRecord<Key extends core.$ZodRecordKey, Value extends Some
|
|
|
1023
1023
|
keyType: Key,
|
|
1024
1024
|
valueType: Value,
|
|
1025
1025
|
params?: string | core.$ZodRecordParams
|
|
1026
|
-
): ZodMiniRecord<
|
|
1026
|
+
): ZodMiniRecord<Key, ZodMiniOptional<Value>> {
|
|
1027
1027
|
return new ZodMiniRecord({
|
|
1028
1028
|
type: "record",
|
|
1029
1029
|
keyType: union([keyType, never()]),
|
|
1030
|
-
valueType: valueType
|
|
1030
|
+
valueType: optional(valueType),
|
|
1031
1031
|
...util.normalizeParams(params),
|
|
1032
1032
|
}) as any;
|
|
1033
1033
|
}
|
|
@@ -99,6 +99,12 @@ test("z.url", () => {
|
|
|
99
99
|
expect(a.parse("http://localhost:3000")).toEqual("http://localhost:3000");
|
|
100
100
|
expect(a.parse("https://localhost:3000")).toEqual("https://localhost:3000");
|
|
101
101
|
|
|
102
|
+
// test trimming
|
|
103
|
+
expect(a.parse(" http://example.com ")).toEqual("http://example.com");
|
|
104
|
+
expect(a.parse(" http://example.com/")).toEqual("http://example.com/");
|
|
105
|
+
expect(a.parse(" http://example.com")).toEqual("http://example.com");
|
|
106
|
+
expect(a.parse(" http://example.com//")).toEqual("http://example.com//");
|
|
107
|
+
|
|
102
108
|
// invalid URLs
|
|
103
109
|
expect(() => a.parse("not-a-url")).toThrow();
|
|
104
110
|
// expect(() => a.parse("http:/example.com")).toThrow();
|
package/v4/classic/schemas.cjs
CHANGED
|
@@ -717,7 +717,7 @@ function partialRecord(keyType, valueType, params) {
|
|
|
717
717
|
return new exports.ZodRecord({
|
|
718
718
|
type: "record",
|
|
719
719
|
keyType: union([keyType, never()]),
|
|
720
|
-
valueType: valueType,
|
|
720
|
+
valueType: optional(valueType),
|
|
721
721
|
...index_js_1.util.normalizeParams(params),
|
|
722
722
|
});
|
|
723
723
|
}
|
package/v4/classic/schemas.d.cts
CHANGED
|
@@ -151,6 +151,7 @@ export interface ZodString extends _ZodString<core.$ZodStringInternals<string>>
|
|
|
151
151
|
}
|
|
152
152
|
export declare const ZodString: core.$constructor<ZodString>;
|
|
153
153
|
export declare function string(params?: string | core.$ZodStringParams): ZodString;
|
|
154
|
+
export declare function string<T extends string>(params?: string | core.$ZodStringParams): core.$ZodType<T, T>;
|
|
154
155
|
export interface ZodStringFormat<Format extends string = string> extends _ZodString<core.$ZodStringFormatInternals<Format>> {
|
|
155
156
|
}
|
|
156
157
|
export declare const ZodStringFormat: core.$constructor<ZodStringFormat>;
|
|
@@ -474,7 +475,7 @@ export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey,
|
|
|
474
475
|
}
|
|
475
476
|
export declare const ZodRecord: core.$constructor<ZodRecord>;
|
|
476
477
|
export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
|
|
477
|
-
export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<
|
|
478
|
+
export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, ZodOptional<Value>>;
|
|
478
479
|
export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
|
|
479
480
|
keyType: Key;
|
|
480
481
|
valueType: Value;
|
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -151,6 +151,7 @@ export interface ZodString extends _ZodString<core.$ZodStringInternals<string>>
|
|
|
151
151
|
}
|
|
152
152
|
export declare const ZodString: core.$constructor<ZodString>;
|
|
153
153
|
export declare function string(params?: string | core.$ZodStringParams): ZodString;
|
|
154
|
+
export declare function string<T extends string>(params?: string | core.$ZodStringParams): core.$ZodType<T, T>;
|
|
154
155
|
export interface ZodStringFormat<Format extends string = string> extends _ZodString<core.$ZodStringFormatInternals<Format>> {
|
|
155
156
|
}
|
|
156
157
|
export declare const ZodStringFormat: core.$constructor<ZodStringFormat>;
|
|
@@ -474,7 +475,7 @@ export interface ZodRecord<Key extends core.$ZodRecordKey = core.$ZodRecordKey,
|
|
|
474
475
|
}
|
|
475
476
|
export declare const ZodRecord: core.$constructor<ZodRecord>;
|
|
476
477
|
export declare function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, Value>;
|
|
477
|
-
export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<
|
|
478
|
+
export declare function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(keyType: Key, valueType: Value, params?: string | core.$ZodRecordParams): ZodRecord<Key, ZodOptional<Value>>;
|
|
478
479
|
export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodMapInternals<Key, Value>>, core.$ZodMap<Key, Value> {
|
|
479
480
|
keyType: Key;
|
|
480
481
|
valueType: Value;
|
package/v4/classic/schemas.js
CHANGED
|
@@ -612,7 +612,7 @@ export function partialRecord(keyType, valueType, params) {
|
|
|
612
612
|
return new ZodRecord({
|
|
613
613
|
type: "record",
|
|
614
614
|
keyType: union([keyType, never()]),
|
|
615
|
-
valueType: valueType,
|
|
615
|
+
valueType: optional(valueType),
|
|
616
616
|
...util.normalizeParams(params),
|
|
617
617
|
});
|
|
618
618
|
}
|
package/v4/core/schemas.cjs
CHANGED
|
@@ -38,8 +38,6 @@ const versions_js_1 = require("./versions.cjs");
|
|
|
38
38
|
exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
39
39
|
var _a;
|
|
40
40
|
inst ?? (inst = {});
|
|
41
|
-
// avoids issues with using Math.random() in Next.js caching
|
|
42
|
-
util.defineLazy(inst._zod, "id", () => def.type + "_" + util.randomString(10));
|
|
43
41
|
inst._zod.def = def; // set _def property
|
|
44
42
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
45
43
|
inst._zod.version = versions_js_1.version;
|
|
@@ -189,7 +187,9 @@ exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
|
|
|
189
187
|
exports.$ZodStringFormat.init(inst, def);
|
|
190
188
|
inst._zod.check = (payload) => {
|
|
191
189
|
try {
|
|
192
|
-
const
|
|
190
|
+
const orig = payload.value;
|
|
191
|
+
const url = new URL(orig);
|
|
192
|
+
const href = url.href;
|
|
193
193
|
if (def.hostname) {
|
|
194
194
|
def.hostname.lastIndex = 0;
|
|
195
195
|
if (!def.hostname.test(url.hostname)) {
|
|
@@ -218,6 +218,13 @@ exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
|
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
+
// payload.value = url.href;
|
|
222
|
+
if (!orig.endsWith("/") && href.endsWith("/")) {
|
|
223
|
+
payload.value = href.slice(0, -1);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
payload.value = href;
|
|
227
|
+
}
|
|
221
228
|
return;
|
|
222
229
|
}
|
|
223
230
|
catch (_) {
|
|
@@ -546,6 +553,8 @@ exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
|
|
|
546
553
|
exports.$ZodType.init(inst, def);
|
|
547
554
|
inst._zod.pattern = regexes.undefined;
|
|
548
555
|
inst._zod.values = new Set([undefined]);
|
|
556
|
+
inst._zod.optin = "optional";
|
|
557
|
+
inst._zod.optout = "optional";
|
|
549
558
|
inst._zod.parse = (payload, _ctx) => {
|
|
550
559
|
const input = payload.value;
|
|
551
560
|
if (typeof input === "undefined")
|
|
@@ -749,8 +758,9 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
749
758
|
};
|
|
750
759
|
doc.write(`const input = payload.value;`);
|
|
751
760
|
const ids = Object.create(null);
|
|
761
|
+
let counter = 0;
|
|
752
762
|
for (const key of normalized.keys) {
|
|
753
|
-
ids[key] =
|
|
763
|
+
ids[key] = `key_${counter++}`;
|
|
754
764
|
}
|
|
755
765
|
// A: preserve key order {
|
|
756
766
|
doc.write(`const newResult = {}`);
|
|
@@ -909,6 +919,8 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
909
919
|
}
|
|
910
920
|
exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
|
911
921
|
exports.$ZodType.init(inst, def);
|
|
922
|
+
util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
|
923
|
+
util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
912
924
|
util.defineLazy(inst._zod, "values", () => {
|
|
913
925
|
if (def.options.every((o) => o._zod.values)) {
|
|
914
926
|
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
@@ -1550,7 +1562,7 @@ exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
|
|
|
1550
1562
|
});
|
|
1551
1563
|
exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
|
1552
1564
|
exports.$ZodType.init(inst, def);
|
|
1553
|
-
|
|
1565
|
+
inst._zod.optin = "optional";
|
|
1554
1566
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1555
1567
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1556
1568
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1622,6 +1634,7 @@ function handlePipeResult(left, def, ctx) {
|
|
|
1622
1634
|
exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1623
1635
|
exports.$ZodType.init(inst, def);
|
|
1624
1636
|
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1637
|
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1625
1638
|
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1626
1639
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1627
1640
|
inst._zod.parse = (payload, ctx) => {
|
package/v4/core/schemas.d.cts
CHANGED
|
@@ -32,7 +32,6 @@ export interface _$ZodTypeInternals {
|
|
|
32
32
|
/** Schema definition. */
|
|
33
33
|
def: $ZodTypeDef;
|
|
34
34
|
/** @internal Randomly generated ID for this schema. */
|
|
35
|
-
id: string;
|
|
36
35
|
/** @internal List of deferred initializers. */
|
|
37
36
|
deferred: util.AnyFunc[] | undefined;
|
|
38
37
|
/** @internal Parses input and runs all checks (refinements). */
|
|
@@ -516,11 +515,13 @@ export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef
|
|
|
516
515
|
type: "array";
|
|
517
516
|
element: T;
|
|
518
517
|
}
|
|
519
|
-
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
518
|
+
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
|
520
519
|
def: $ZodArrayDef<T>;
|
|
521
520
|
isst: errors.$ZodIssueInvalidType;
|
|
521
|
+
output: core.output<T>[];
|
|
522
|
+
input: core.input<T>[];
|
|
522
523
|
}
|
|
523
|
-
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<
|
|
524
|
+
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {
|
|
524
525
|
}
|
|
525
526
|
export declare const $ZodArray: core.$constructor<$ZodArray>;
|
|
526
527
|
type OptionalOutSchema = {
|
|
@@ -533,12 +534,12 @@ type OptionalInSchema = {
|
|
|
533
534
|
optin: "optional";
|
|
534
535
|
};
|
|
535
536
|
};
|
|
536
|
-
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? Record<string, unknown> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
537
|
+
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
537
538
|
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
|
|
538
539
|
} & {
|
|
539
540
|
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
|
|
540
541
|
} & Extra>;
|
|
541
|
-
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? Record<string, unknown> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
542
|
+
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
542
543
|
-readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
|
|
543
544
|
} & {
|
|
544
545
|
-readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
|
|
@@ -598,12 +599,19 @@ export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $Zo
|
|
|
598
599
|
type: "union";
|
|
599
600
|
options: Options;
|
|
600
601
|
}
|
|
601
|
-
|
|
602
|
+
type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
|
|
603
|
+
type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
|
|
604
|
+
export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
|
|
602
605
|
def: $ZodUnionDef<T>;
|
|
603
606
|
isst: errors.$ZodIssueInvalidUnion;
|
|
604
607
|
pattern: T[number]["_zod"]["pattern"];
|
|
608
|
+
values: T[number]["_zod"]["values"];
|
|
609
|
+
output: $InferUnionOutput<T[number]>;
|
|
610
|
+
input: $InferUnionInput<T[number]>;
|
|
611
|
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
|
612
|
+
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
|
605
613
|
}
|
|
606
|
-
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType {
|
|
614
|
+
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
|
607
615
|
_zod: $ZodUnionInternals<T>;
|
|
608
616
|
}
|
|
609
617
|
export declare const $ZodUnion: core.$constructor<$ZodUnion>;
|
|
@@ -673,8 +681,8 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
|
|
|
673
681
|
keyType: Key;
|
|
674
682
|
valueType: Value;
|
|
675
683
|
}
|
|
676
|
-
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : number extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : symbol extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> :
|
|
677
|
-
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : number extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : symbol extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> :
|
|
684
|
+
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : number extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : symbol extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>>;
|
|
685
|
+
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : number extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : symbol extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>>;
|
|
678
686
|
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
|
|
679
687
|
def: $ZodRecordDef<Key, Value>;
|
|
680
688
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
@@ -924,6 +932,7 @@ export interface $ZodReadonlyInternals<T extends SomeType = $ZodType> extends $Z
|
|
|
924
932
|
optout: T["_zod"]["optout"];
|
|
925
933
|
isst: never;
|
|
926
934
|
propValues: T["_zod"]["propValues"];
|
|
935
|
+
values: T["_zod"]["values"];
|
|
927
936
|
}
|
|
928
937
|
export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
|
|
929
938
|
_zod: $ZodReadonlyInternals<T>;
|
package/v4/core/schemas.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface _$ZodTypeInternals {
|
|
|
32
32
|
/** Schema definition. */
|
|
33
33
|
def: $ZodTypeDef;
|
|
34
34
|
/** @internal Randomly generated ID for this schema. */
|
|
35
|
-
id: string;
|
|
36
35
|
/** @internal List of deferred initializers. */
|
|
37
36
|
deferred: util.AnyFunc[] | undefined;
|
|
38
37
|
/** @internal Parses input and runs all checks (refinements). */
|
|
@@ -516,11 +515,13 @@ export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef
|
|
|
516
515
|
type: "array";
|
|
517
516
|
element: T;
|
|
518
517
|
}
|
|
519
|
-
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
518
|
+
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
|
520
519
|
def: $ZodArrayDef<T>;
|
|
521
520
|
isst: errors.$ZodIssueInvalidType;
|
|
521
|
+
output: core.output<T>[];
|
|
522
|
+
input: core.input<T>[];
|
|
522
523
|
}
|
|
523
|
-
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<
|
|
524
|
+
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {
|
|
524
525
|
}
|
|
525
526
|
export declare const $ZodArray: core.$constructor<$ZodArray>;
|
|
526
527
|
type OptionalOutSchema = {
|
|
@@ -533,12 +534,12 @@ type OptionalInSchema = {
|
|
|
533
534
|
optin: "optional";
|
|
534
535
|
};
|
|
535
536
|
};
|
|
536
|
-
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? Record<string, unknown> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
537
|
+
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
537
538
|
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
|
|
538
539
|
} & {
|
|
539
540
|
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
|
|
540
541
|
} & Extra>;
|
|
541
|
-
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? Record<string, unknown> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
542
|
+
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
|
542
543
|
-readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
|
|
543
544
|
} & {
|
|
544
545
|
-readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
|
|
@@ -598,12 +599,19 @@ export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $Zo
|
|
|
598
599
|
type: "union";
|
|
599
600
|
options: Options;
|
|
600
601
|
}
|
|
601
|
-
|
|
602
|
+
type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
|
|
603
|
+
type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
|
|
604
|
+
export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
|
|
602
605
|
def: $ZodUnionDef<T>;
|
|
603
606
|
isst: errors.$ZodIssueInvalidUnion;
|
|
604
607
|
pattern: T[number]["_zod"]["pattern"];
|
|
608
|
+
values: T[number]["_zod"]["values"];
|
|
609
|
+
output: $InferUnionOutput<T[number]>;
|
|
610
|
+
input: $InferUnionInput<T[number]>;
|
|
611
|
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
|
612
|
+
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
|
605
613
|
}
|
|
606
|
-
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType {
|
|
614
|
+
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
|
607
615
|
_zod: $ZodUnionInternals<T>;
|
|
608
616
|
}
|
|
609
617
|
export declare const $ZodUnion: core.$constructor<$ZodUnion>;
|
|
@@ -673,8 +681,8 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
|
|
|
673
681
|
keyType: Key;
|
|
674
682
|
valueType: Value;
|
|
675
683
|
}
|
|
676
|
-
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : number extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : symbol extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> :
|
|
677
|
-
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : number extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : symbol extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> :
|
|
684
|
+
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : number extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : symbol extends core.output<Key> ? Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>> : Record<core.output<Key>, core.output<Value>>;
|
|
685
|
+
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = undefined extends Key["_zod"]["values"] ? string extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : number extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : symbol extends core.input<Key> ? Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>> : Record<core.input<Key>, core.input<Value>>;
|
|
678
686
|
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
|
|
679
687
|
def: $ZodRecordDef<Key, Value>;
|
|
680
688
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
@@ -924,6 +932,7 @@ export interface $ZodReadonlyInternals<T extends SomeType = $ZodType> extends $Z
|
|
|
924
932
|
optout: T["_zod"]["optout"];
|
|
925
933
|
isst: never;
|
|
926
934
|
propValues: T["_zod"]["propValues"];
|
|
935
|
+
values: T["_zod"]["values"];
|
|
927
936
|
}
|
|
928
937
|
export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
|
|
929
938
|
_zod: $ZodReadonlyInternals<T>;
|
package/v4/core/schemas.js
CHANGED
|
@@ -8,8 +8,6 @@ import { version } from "./versions.js";
|
|
|
8
8
|
export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
|
|
9
9
|
var _a;
|
|
10
10
|
inst ?? (inst = {});
|
|
11
|
-
// avoids issues with using Math.random() in Next.js caching
|
|
12
|
-
util.defineLazy(inst._zod, "id", () => def.type + "_" + util.randomString(10));
|
|
13
11
|
inst._zod.def = def; // set _def property
|
|
14
12
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
15
13
|
inst._zod.version = version;
|
|
@@ -158,7 +156,9 @@ export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) =>
|
|
|
158
156
|
$ZodStringFormat.init(inst, def);
|
|
159
157
|
inst._zod.check = (payload) => {
|
|
160
158
|
try {
|
|
161
|
-
const
|
|
159
|
+
const orig = payload.value;
|
|
160
|
+
const url = new URL(orig);
|
|
161
|
+
const href = url.href;
|
|
162
162
|
if (def.hostname) {
|
|
163
163
|
def.hostname.lastIndex = 0;
|
|
164
164
|
if (!def.hostname.test(url.hostname)) {
|
|
@@ -187,6 +187,13 @@ export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) =>
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
+
// payload.value = url.href;
|
|
191
|
+
if (!orig.endsWith("/") && href.endsWith("/")) {
|
|
192
|
+
payload.value = href.slice(0, -1);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
payload.value = href;
|
|
196
|
+
}
|
|
190
197
|
return;
|
|
191
198
|
}
|
|
192
199
|
catch (_) {
|
|
@@ -515,6 +522,8 @@ export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (i
|
|
|
515
522
|
$ZodType.init(inst, def);
|
|
516
523
|
inst._zod.pattern = regexes.undefined;
|
|
517
524
|
inst._zod.values = new Set([undefined]);
|
|
525
|
+
inst._zod.optin = "optional";
|
|
526
|
+
inst._zod.optout = "optional";
|
|
518
527
|
inst._zod.parse = (payload, _ctx) => {
|
|
519
528
|
const input = payload.value;
|
|
520
529
|
if (typeof input === "undefined")
|
|
@@ -718,8 +727,9 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
718
727
|
};
|
|
719
728
|
doc.write(`const input = payload.value;`);
|
|
720
729
|
const ids = Object.create(null);
|
|
730
|
+
let counter = 0;
|
|
721
731
|
for (const key of normalized.keys) {
|
|
722
|
-
ids[key] =
|
|
732
|
+
ids[key] = `key_${counter++}`;
|
|
723
733
|
}
|
|
724
734
|
// A: preserve key order {
|
|
725
735
|
doc.write(`const newResult = {}`);
|
|
@@ -878,6 +888,8 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
878
888
|
}
|
|
879
889
|
export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
|
880
890
|
$ZodType.init(inst, def);
|
|
891
|
+
util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
|
892
|
+
util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
881
893
|
util.defineLazy(inst._zod, "values", () => {
|
|
882
894
|
if (def.options.every((o) => o._zod.values)) {
|
|
883
895
|
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
@@ -1519,7 +1531,7 @@ export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst,
|
|
|
1519
1531
|
});
|
|
1520
1532
|
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
1521
1533
|
$ZodType.init(inst, def);
|
|
1522
|
-
|
|
1534
|
+
inst._zod.optin = "optional";
|
|
1523
1535
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1524
1536
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1525
1537
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1591,6 +1603,7 @@ function handlePipeResult(left, def, ctx) {
|
|
|
1591
1603
|
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1592
1604
|
$ZodType.init(inst, def);
|
|
1593
1605
|
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1606
|
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1594
1607
|
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1595
1608
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1596
1609
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -36,7 +36,7 @@ class JSONSchemaGenerator {
|
|
|
36
36
|
return seen.schema;
|
|
37
37
|
}
|
|
38
38
|
// initialize
|
|
39
|
-
const result = { schema: {}, count: 1, cycle: undefined };
|
|
39
|
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
40
40
|
this.seen.set(schema, result);
|
|
41
41
|
// custom method overrides default behavior
|
|
42
42
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
@@ -141,11 +141,6 @@ class JSONSchemaGenerator {
|
|
|
141
141
|
}
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
|
-
case "undefined": {
|
|
145
|
-
const json = _json;
|
|
146
|
-
json.type = "null";
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
144
|
case "null": {
|
|
150
145
|
_json.type = "null";
|
|
151
146
|
break;
|
|
@@ -156,6 +151,7 @@ class JSONSchemaGenerator {
|
|
|
156
151
|
case "unknown": {
|
|
157
152
|
break;
|
|
158
153
|
}
|
|
154
|
+
case "undefined":
|
|
159
155
|
case "never": {
|
|
160
156
|
_json.not = {};
|
|
161
157
|
break;
|
|
@@ -654,6 +650,7 @@ class JSONSchemaGenerator {
|
|
|
654
650
|
this.override({
|
|
655
651
|
zodSchema: zodSchema,
|
|
656
652
|
jsonSchema: schema,
|
|
653
|
+
path: seen.path ?? [],
|
|
657
654
|
});
|
|
658
655
|
};
|
|
659
656
|
for (const entry of [...this.seen.entries()].reverse()) {
|
|
@@ -17,9 +17,10 @@ interface JSONSchemaGeneratorParams {
|
|
|
17
17
|
override?: (ctx: {
|
|
18
18
|
zodSchema: schemas.$ZodTypes;
|
|
19
19
|
jsonSchema: JSONSchema.BaseSchema;
|
|
20
|
+
path: (string | number)[];
|
|
20
21
|
}) => void;
|
|
21
22
|
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
|
|
22
|
-
* - `"output" —
|
|
23
|
+
* - `"output"` — Default. Convert the output schema.
|
|
23
24
|
* - `"input"` — Convert the input schema. */
|
|
24
25
|
io?: "input" | "output";
|
|
25
26
|
}
|
|
@@ -54,6 +55,8 @@ interface Seen {
|
|
|
54
55
|
cycle?: (string | number)[] | undefined;
|
|
55
56
|
isParent?: boolean | undefined;
|
|
56
57
|
ref?: schemas.$ZodType | undefined | null;
|
|
58
|
+
/** JSON Schema property path for this schema */
|
|
59
|
+
path?: (string | number)[] | undefined;
|
|
57
60
|
}
|
|
58
61
|
export declare class JSONSchemaGenerator {
|
|
59
62
|
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
|
@@ -62,6 +65,7 @@ export declare class JSONSchemaGenerator {
|
|
|
62
65
|
override: (ctx: {
|
|
63
66
|
zodSchema: schemas.$ZodTypes;
|
|
64
67
|
jsonSchema: JSONSchema.BaseSchema;
|
|
68
|
+
path: (string | number)[];
|
|
65
69
|
}) => void;
|
|
66
70
|
io: "input" | "output";
|
|
67
71
|
counter: number;
|
|
@@ -17,9 +17,10 @@ interface JSONSchemaGeneratorParams {
|
|
|
17
17
|
override?: (ctx: {
|
|
18
18
|
zodSchema: schemas.$ZodTypes;
|
|
19
19
|
jsonSchema: JSONSchema.BaseSchema;
|
|
20
|
+
path: (string | number)[];
|
|
20
21
|
}) => void;
|
|
21
22
|
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
|
|
22
|
-
* - `"output" —
|
|
23
|
+
* - `"output"` — Default. Convert the output schema.
|
|
23
24
|
* - `"input"` — Convert the input schema. */
|
|
24
25
|
io?: "input" | "output";
|
|
25
26
|
}
|
|
@@ -54,6 +55,8 @@ interface Seen {
|
|
|
54
55
|
cycle?: (string | number)[] | undefined;
|
|
55
56
|
isParent?: boolean | undefined;
|
|
56
57
|
ref?: schemas.$ZodType | undefined | null;
|
|
58
|
+
/** JSON Schema property path for this schema */
|
|
59
|
+
path?: (string | number)[] | undefined;
|
|
57
60
|
}
|
|
58
61
|
export declare class JSONSchemaGenerator {
|
|
59
62
|
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
|
@@ -62,6 +65,7 @@ export declare class JSONSchemaGenerator {
|
|
|
62
65
|
override: (ctx: {
|
|
63
66
|
zodSchema: schemas.$ZodTypes;
|
|
64
67
|
jsonSchema: JSONSchema.BaseSchema;
|
|
68
|
+
path: (string | number)[];
|
|
65
69
|
}) => void;
|
|
66
70
|
io: "input" | "output";
|
|
67
71
|
counter: number;
|