zod 4.0.5 → 4.0.7
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/package.json +1 -1
- package/src/v3/tests/string.test.ts +2 -2
- package/src/v3/types.ts +3 -1
- package/src/v4/classic/errors.ts +9 -2
- package/src/v4/classic/schemas.ts +11 -9
- package/src/v4/classic/tests/catch.test.ts +4 -5
- package/src/v4/classic/tests/discriminated-unions.test.ts +12 -0
- package/src/v4/classic/tests/error-utils.test.ts +43 -0
- package/src/v4/classic/tests/literal.test.ts +25 -0
- package/src/v4/classic/tests/partial.test.ts +193 -0
- package/src/v4/classic/tests/pickomit.test.ts +5 -5
- package/src/v4/classic/tests/preprocess.test.ts +4 -15
- package/src/v4/classic/tests/record.test.ts +15 -1
- package/src/v4/classic/tests/recursive-types.test.ts +67 -0
- package/src/v4/classic/tests/string.test.ts +81 -4
- package/src/v4/classic/tests/template-literal.test.ts +3 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +1 -0
- package/src/v4/classic/tests/transform.test.ts +104 -0
- package/src/v4/classic/tests/union.test.ts +45 -3
- package/src/v4/core/checks.ts +2 -2
- package/src/v4/core/errors.ts +8 -15
- package/src/v4/core/regexes.ts +1 -1
- package/src/v4/core/registries.ts +3 -2
- package/src/v4/core/schemas.ts +91 -99
- package/src/v4/core/to-json-schema.ts +1 -0
- package/src/v4/core/util.ts +175 -115
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/locales/bg.ts +136 -0
- package/src/v4/locales/da.ts +141 -0
- package/src/v4/locales/index.ts +2 -0
- package/src/v4/locales/is.ts +127 -0
- package/src/v4/mini/schemas.ts +3 -1
- package/v3/types.cjs +2 -0
- package/v3/types.d.cts +4 -1
- package/v3/types.d.ts +4 -1
- package/v3/types.js +2 -0
- package/v4/classic/errors.cjs +9 -2
- package/v4/classic/errors.js +9 -2
- package/v4/classic/schemas.cjs +5 -3
- package/v4/classic/schemas.d.cts +3 -3
- package/v4/classic/schemas.d.ts +3 -3
- package/v4/classic/schemas.js +5 -3
- package/v4/core/checks.d.cts +2 -2
- package/v4/core/checks.d.ts +2 -2
- package/v4/core/errors.cjs +4 -9
- package/v4/core/errors.d.cts +4 -6
- package/v4/core/errors.d.ts +4 -6
- package/v4/core/errors.js +4 -9
- package/v4/core/regexes.cjs +1 -1
- package/v4/core/regexes.d.cts +1 -1
- package/v4/core/regexes.d.ts +1 -1
- package/v4/core/regexes.js +1 -1
- package/v4/core/registries.cjs +2 -1
- package/v4/core/registries.d.cts +1 -1
- package/v4/core/registries.d.ts +1 -1
- package/v4/core/registries.js +2 -1
- package/v4/core/schemas.cjs +48 -88
- package/v4/core/schemas.d.cts +9 -4
- package/v4/core/schemas.d.ts +9 -4
- package/v4/core/schemas.js +48 -88
- package/v4/core/to-json-schema.cjs +1 -0
- package/v4/core/to-json-schema.js +1 -0
- package/v4/core/util.cjs +163 -112
- package/v4/core/util.d.cts +1 -0
- package/v4/core/util.d.ts +1 -0
- package/v4/core/util.js +162 -112
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
- package/v4/locales/bg.cjs +156 -0
- package/v4/locales/bg.d.cts +5 -0
- package/v4/locales/bg.d.ts +5 -0
- package/v4/locales/bg.js +128 -0
- package/v4/locales/da.cjs +157 -0
- package/v4/locales/da.d.cts +4 -0
- package/v4/locales/da.d.ts +4 -0
- package/v4/locales/da.js +131 -0
- package/v4/locales/index.cjs +5 -1
- package/v4/locales/index.d.cts +2 -0
- package/v4/locales/index.d.ts +2 -0
- package/v4/locales/index.js +2 -0
- package/v4/locales/is.cjs +145 -0
- package/v4/locales/is.d.cts +5 -0
- package/v4/locales/is.d.ts +5 -0
- package/v4/locales/is.js +117 -0
- package/v4/mini/schemas.cjs +3 -1
- package/v4/mini/schemas.js +3 -1
|
@@ -0,0 +1,127 @@
|
|
|
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" : "númer";
|
|
11
|
+
}
|
|
12
|
+
case "object": {
|
|
13
|
+
if (Array.isArray(data)) {
|
|
14
|
+
return "fylki";
|
|
15
|
+
}
|
|
16
|
+
if (data === null) {
|
|
17
|
+
return "null";
|
|
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: "stafi", verb: "að hafa" },
|
|
31
|
+
file: { unit: "bæti", verb: "að hafa" },
|
|
32
|
+
array: { unit: "hluti", verb: "að hafa" },
|
|
33
|
+
set: { unit: "hluti", verb: "að hafa" },
|
|
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: "gildi",
|
|
44
|
+
email: "netfang",
|
|
45
|
+
url: "vefslóð",
|
|
46
|
+
emoji: "emoji",
|
|
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 dagsetning og tími",
|
|
58
|
+
date: "ISO dagsetning",
|
|
59
|
+
time: "ISO tími",
|
|
60
|
+
duration: "ISO tímalengd",
|
|
61
|
+
ipv4: "IPv4 address",
|
|
62
|
+
ipv6: "IPv6 address",
|
|
63
|
+
cidrv4: "IPv4 range",
|
|
64
|
+
cidrv6: "IPv6 range",
|
|
65
|
+
base64: "base64-encoded strengur",
|
|
66
|
+
base64url: "base64url-encoded strengur",
|
|
67
|
+
json_string: "JSON strengur",
|
|
68
|
+
e164: "E.164 tölugildi",
|
|
69
|
+
jwt: "JWT",
|
|
70
|
+
template_literal: "gildi",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (issue) => {
|
|
74
|
+
switch (issue.code) {
|
|
75
|
+
case "invalid_type":
|
|
76
|
+
return `Rangt gildi: Þú slóst inn ${parsedType(issue.input)} þar sem á að vera ${issue.expected}`;
|
|
77
|
+
|
|
78
|
+
case "invalid_value":
|
|
79
|
+
if (issue.values.length === 1) return `Rangt gildi: gert ráð fyrir ${util.stringifyPrimitive(issue.values[0])}`;
|
|
80
|
+
return `Ógilt val: má vera eitt af eftirfarandi ${util.joinValues(issue.values, "|")}`;
|
|
81
|
+
case "too_big": {
|
|
82
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
83
|
+
const sizing = getSizing(issue.origin);
|
|
84
|
+
if (sizing)
|
|
85
|
+
return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} hafi ${adj}${issue.maximum.toString()} ${sizing.unit ?? "hluti"}`;
|
|
86
|
+
return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} sé ${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 `Of lítið: gert er ráð fyrir að ${issue.origin} hafi ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return `Of lítið: gert er ráð fyrir að ${issue.origin} sé ${adj}${issue.minimum.toString()}`;
|
|
96
|
+
}
|
|
97
|
+
case "invalid_format": {
|
|
98
|
+
const _issue = issue as errors.$ZodStringFormatIssues;
|
|
99
|
+
if (_issue.format === "starts_with") {
|
|
100
|
+
return `Ógildur strengur: verður að byrja á "${_issue.prefix}"`;
|
|
101
|
+
}
|
|
102
|
+
if (_issue.format === "ends_with") return `Ógildur strengur: verður að enda á "${_issue.suffix}"`;
|
|
103
|
+
if (_issue.format === "includes") return `Ógildur strengur: verður að innihalda "${_issue.includes}"`;
|
|
104
|
+
if (_issue.format === "regex") return `Ógildur strengur: verður að fylgja mynstri ${_issue.pattern}`;
|
|
105
|
+
return `Rangt ${Nouns[_issue.format] ?? issue.format}`;
|
|
106
|
+
}
|
|
107
|
+
case "not_multiple_of":
|
|
108
|
+
return `Röng tala: verður að vera margfeldi af ${issue.divisor}`;
|
|
109
|
+
case "unrecognized_keys":
|
|
110
|
+
return `Óþekkt ${issue.keys.length > 1 ? "ir lyklar" : "ur lykill"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
111
|
+
case "invalid_key":
|
|
112
|
+
return `Rangur lykill í ${issue.origin}`;
|
|
113
|
+
case "invalid_union":
|
|
114
|
+
return "Rangt gildi";
|
|
115
|
+
case "invalid_element":
|
|
116
|
+
return `Rangt gildi í ${issue.origin}`;
|
|
117
|
+
default:
|
|
118
|
+
return `Rangt gildi`;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default function (): { localeError: errors.$ZodErrorMap } {
|
|
124
|
+
return {
|
|
125
|
+
localeError: error(),
|
|
126
|
+
};
|
|
127
|
+
}
|
package/src/v4/mini/schemas.ts
CHANGED
|
@@ -1024,9 +1024,11 @@ export function partialRecord<Key extends core.$ZodRecordKey, Value extends Some
|
|
|
1024
1024
|
valueType: Value,
|
|
1025
1025
|
params?: string | core.$ZodRecordParams
|
|
1026
1026
|
): ZodMiniRecord<Key & core.$partial, Value> {
|
|
1027
|
+
const k = core.clone(keyType);
|
|
1028
|
+
k._zod.values = undefined;
|
|
1027
1029
|
return new ZodMiniRecord({
|
|
1028
1030
|
type: "record",
|
|
1029
|
-
keyType:
|
|
1031
|
+
keyType: k,
|
|
1030
1032
|
valueType: valueType as any,
|
|
1031
1033
|
...util.normalizeParams(params),
|
|
1032
1034
|
}) as any;
|
package/v3/types.cjs
CHANGED
|
@@ -459,6 +459,7 @@ function isValidJWT(jwt, alg) {
|
|
|
459
459
|
.replace(/-/g, "+")
|
|
460
460
|
.replace(/_/g, "/")
|
|
461
461
|
.padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
|
|
462
|
+
// @ts-ignore
|
|
462
463
|
const decoded = JSON.parse(atob(base64));
|
|
463
464
|
if (typeof decoded !== "object" || decoded === null)
|
|
464
465
|
return false;
|
|
@@ -639,6 +640,7 @@ class ZodString extends ZodType {
|
|
|
639
640
|
}
|
|
640
641
|
else if (check.kind === "url") {
|
|
641
642
|
try {
|
|
643
|
+
// @ts-ignore
|
|
642
644
|
new URL(input.data);
|
|
643
645
|
}
|
|
644
646
|
catch {
|
package/v3/types.d.cts
CHANGED
|
@@ -527,7 +527,10 @@ export type noUnrecognized<Obj extends object, Shape extends object> = {
|
|
|
527
527
|
[k in keyof Obj]: k extends keyof Shape ? Obj[k] : never;
|
|
528
528
|
};
|
|
529
529
|
export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
|
|
530
|
-
|
|
530
|
+
_cached: {
|
|
531
|
+
shape: T;
|
|
532
|
+
keys: string[];
|
|
533
|
+
} | null;
|
|
531
534
|
_getCached(): {
|
|
532
535
|
shape: T;
|
|
533
536
|
keys: string[];
|
package/v3/types.d.ts
CHANGED
|
@@ -527,7 +527,10 @@ export type noUnrecognized<Obj extends object, Shape extends object> = {
|
|
|
527
527
|
[k in keyof Obj]: k extends keyof Shape ? Obj[k] : never;
|
|
528
528
|
};
|
|
529
529
|
export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
|
|
530
|
-
|
|
530
|
+
_cached: {
|
|
531
|
+
shape: T;
|
|
532
|
+
keys: string[];
|
|
533
|
+
} | null;
|
|
531
534
|
_getCached(): {
|
|
532
535
|
shape: T;
|
|
533
536
|
keys: string[];
|
package/v3/types.js
CHANGED
|
@@ -450,6 +450,7 @@ function isValidJWT(jwt, alg) {
|
|
|
450
450
|
.replace(/-/g, "+")
|
|
451
451
|
.replace(/_/g, "/")
|
|
452
452
|
.padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
|
|
453
|
+
// @ts-ignore
|
|
453
454
|
const decoded = JSON.parse(atob(base64));
|
|
454
455
|
if (typeof decoded !== "object" || decoded === null)
|
|
455
456
|
return false;
|
|
@@ -630,6 +631,7 @@ export class ZodString extends ZodType {
|
|
|
630
631
|
}
|
|
631
632
|
else if (check.kind === "url") {
|
|
632
633
|
try {
|
|
634
|
+
// @ts-ignore
|
|
633
635
|
new URL(input.data);
|
|
634
636
|
}
|
|
635
637
|
catch {
|
package/v4/classic/errors.cjs
CHANGED
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.ZodRealError = exports.ZodError = void 0;
|
|
27
27
|
const core = __importStar(require("../core/index.cjs"));
|
|
28
28
|
const index_js_1 = require("../core/index.cjs");
|
|
29
|
+
const util = __importStar(require("../core/util.cjs"));
|
|
29
30
|
const initializer = (inst, issues) => {
|
|
30
31
|
index_js_1.$ZodError.init(inst, issues);
|
|
31
32
|
inst.name = "ZodError";
|
|
@@ -39,11 +40,17 @@ const initializer = (inst, issues) => {
|
|
|
39
40
|
// enumerable: false,
|
|
40
41
|
},
|
|
41
42
|
addIssue: {
|
|
42
|
-
value: (issue) =>
|
|
43
|
+
value: (issue) => {
|
|
44
|
+
inst.issues.push(issue);
|
|
45
|
+
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
46
|
+
},
|
|
43
47
|
// enumerable: false,
|
|
44
48
|
},
|
|
45
49
|
addIssues: {
|
|
46
|
-
value: (issues) =>
|
|
50
|
+
value: (issues) => {
|
|
51
|
+
inst.issues.push(...issues);
|
|
52
|
+
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
53
|
+
},
|
|
47
54
|
// enumerable: false,
|
|
48
55
|
},
|
|
49
56
|
isEmpty: {
|
package/v4/classic/errors.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import { $ZodError } from "../core/index.js";
|
|
3
|
+
import * as util from "../core/util.js";
|
|
3
4
|
const initializer = (inst, issues) => {
|
|
4
5
|
$ZodError.init(inst, issues);
|
|
5
6
|
inst.name = "ZodError";
|
|
@@ -13,11 +14,17 @@ const initializer = (inst, issues) => {
|
|
|
13
14
|
// enumerable: false,
|
|
14
15
|
},
|
|
15
16
|
addIssue: {
|
|
16
|
-
value: (issue) =>
|
|
17
|
+
value: (issue) => {
|
|
18
|
+
inst.issues.push(issue);
|
|
19
|
+
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
20
|
+
},
|
|
17
21
|
// enumerable: false,
|
|
18
22
|
},
|
|
19
23
|
addIssues: {
|
|
20
|
-
value: (issues) =>
|
|
24
|
+
value: (issues) => {
|
|
25
|
+
inst.issues.push(...issues);
|
|
26
|
+
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
27
|
+
},
|
|
21
28
|
// enumerable: false,
|
|
22
29
|
},
|
|
23
30
|
isEmpty: {
|
package/v4/classic/schemas.cjs
CHANGED
|
@@ -595,7 +595,6 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
|
595
595
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
596
596
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
597
597
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
598
|
-
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
599
598
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
600
599
|
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
601
600
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
@@ -714,9 +713,11 @@ function record(keyType, valueType, params) {
|
|
|
714
713
|
}
|
|
715
714
|
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
716
715
|
function partialRecord(keyType, valueType, params) {
|
|
716
|
+
const k = core.clone(keyType);
|
|
717
|
+
k._zod.values = undefined;
|
|
717
718
|
return new exports.ZodRecord({
|
|
718
719
|
type: "record",
|
|
719
|
-
keyType:
|
|
720
|
+
keyType: k,
|
|
720
721
|
valueType: valueType,
|
|
721
722
|
...index_js_1.util.normalizeParams(params),
|
|
722
723
|
});
|
|
@@ -857,7 +858,7 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
|
|
857
858
|
_issue.code ?? (_issue.code = "custom");
|
|
858
859
|
_issue.input ?? (_issue.input = payload.value);
|
|
859
860
|
_issue.inst ?? (_issue.inst = inst);
|
|
860
|
-
|
|
861
|
+
// _issue.continue ??= true;
|
|
861
862
|
payload.issues.push(index_js_1.util.issue(_issue));
|
|
862
863
|
}
|
|
863
864
|
};
|
|
@@ -993,6 +994,7 @@ function pipe(in_, out) {
|
|
|
993
994
|
exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
|
|
994
995
|
core.$ZodReadonly.init(inst, def);
|
|
995
996
|
exports.ZodType.init(inst, def);
|
|
997
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
996
998
|
});
|
|
997
999
|
function readonly(innerType) {
|
|
998
1000
|
return new exports.ZodReadonly({
|
package/v4/classic/schemas.d.cts
CHANGED
|
@@ -25,8 +25,6 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
|
|
|
25
25
|
safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
|
26
26
|
spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
|
27
27
|
refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
|
|
28
|
-
/** @deprecated Use [`.check()`](https://zod.dev/api?id=check) instead.
|
|
29
|
-
*/
|
|
30
28
|
superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
|
|
31
29
|
overwrite(fn: (x: core.output<this>) => core.output<this>): this;
|
|
32
30
|
optional(): ZodOptional<this>;
|
|
@@ -415,7 +413,7 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
|
|
415
413
|
strict(): ZodObject<Shape, core.$strict>;
|
|
416
414
|
/** This is the default behavior. This method call is likely unnecessary. */
|
|
417
415
|
strip(): ZodObject<Shape, core.$strip>;
|
|
418
|
-
extend<U extends core.$ZodLooseShape
|
|
416
|
+
extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
|
419
417
|
/**
|
|
420
418
|
* @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
|
|
421
419
|
*/
|
|
@@ -446,6 +444,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
|
|
|
446
444
|
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
|
447
445
|
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
|
|
448
446
|
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
|
447
|
+
def: core.$ZodDiscriminatedUnionDef<Options>;
|
|
449
448
|
}
|
|
450
449
|
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
|
451
450
|
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
|
|
@@ -573,6 +572,7 @@ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core
|
|
|
573
572
|
export declare const ZodPipe: core.$constructor<ZodPipe>;
|
|
574
573
|
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>;
|
|
575
574
|
export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
|
|
575
|
+
unwrap(): T;
|
|
576
576
|
}
|
|
577
577
|
export declare const ZodReadonly: core.$constructor<ZodReadonly>;
|
|
578
578
|
export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
|
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -25,8 +25,6 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
|
|
|
25
25
|
safeParseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
|
26
26
|
spa: (data: unknown, params?: core.ParseContext<core.$ZodIssue>) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
|
|
27
27
|
refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
|
|
28
|
-
/** @deprecated Use [`.check()`](https://zod.dev/api?id=check) instead.
|
|
29
|
-
*/
|
|
30
28
|
superRefine(refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>): this;
|
|
31
29
|
overwrite(fn: (x: core.output<this>) => core.output<this>): this;
|
|
32
30
|
optional(): ZodOptional<this>;
|
|
@@ -415,7 +413,7 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
|
|
415
413
|
strict(): ZodObject<Shape, core.$strict>;
|
|
416
414
|
/** This is the default behavior. This method call is likely unnecessary. */
|
|
417
415
|
strip(): ZodObject<Shape, core.$strip>;
|
|
418
|
-
extend<U extends core.$ZodLooseShape
|
|
416
|
+
extend<U extends core.$ZodLooseShape>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
|
419
417
|
/**
|
|
420
418
|
* @deprecated Use [`A.extend(B.shape)`](https://zod.dev/api?id=extend) instead.
|
|
421
419
|
*/
|
|
@@ -446,6 +444,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
|
|
|
446
444
|
export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
|
447
445
|
export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
|
|
448
446
|
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
|
447
|
+
def: core.$ZodDiscriminatedUnionDef<Options>;
|
|
449
448
|
}
|
|
450
449
|
export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
|
|
451
450
|
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
|
|
@@ -573,6 +572,7 @@ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core
|
|
|
573
572
|
export declare const ZodPipe: core.$constructor<ZodPipe>;
|
|
574
573
|
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>;
|
|
575
574
|
export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
|
|
575
|
+
unwrap(): T;
|
|
576
576
|
}
|
|
577
577
|
export declare const ZodReadonly: core.$constructor<ZodReadonly>;
|
|
578
578
|
export declare function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T>;
|
package/v4/classic/schemas.js
CHANGED
|
@@ -490,7 +490,6 @@ export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def
|
|
|
490
490
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
491
491
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
492
492
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
493
|
-
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
494
493
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
495
494
|
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
496
495
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
@@ -609,9 +608,11 @@ export function record(keyType, valueType, params) {
|
|
|
609
608
|
}
|
|
610
609
|
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
611
610
|
export function partialRecord(keyType, valueType, params) {
|
|
611
|
+
const k = core.clone(keyType);
|
|
612
|
+
k._zod.values = undefined;
|
|
612
613
|
return new ZodRecord({
|
|
613
614
|
type: "record",
|
|
614
|
-
keyType:
|
|
615
|
+
keyType: k,
|
|
615
616
|
valueType: valueType,
|
|
616
617
|
...util.normalizeParams(params),
|
|
617
618
|
});
|
|
@@ -753,7 +754,7 @@ export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (ins
|
|
|
753
754
|
_issue.code ?? (_issue.code = "custom");
|
|
754
755
|
_issue.input ?? (_issue.input = payload.value);
|
|
755
756
|
_issue.inst ?? (_issue.inst = inst);
|
|
756
|
-
|
|
757
|
+
// _issue.continue ??= true;
|
|
757
758
|
payload.issues.push(util.issue(_issue));
|
|
758
759
|
}
|
|
759
760
|
};
|
|
@@ -890,6 +891,7 @@ export function pipe(in_, out) {
|
|
|
890
891
|
export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst, def) => {
|
|
891
892
|
core.$ZodReadonly.init(inst, def);
|
|
892
893
|
ZodType.init(inst, def);
|
|
894
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
893
895
|
});
|
|
894
896
|
export function readonly(innerType) {
|
|
895
897
|
return new ZodReadonly({
|
package/v4/core/checks.d.cts
CHANGED
|
@@ -254,11 +254,11 @@ export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
|
|
|
254
254
|
check: "mime_type";
|
|
255
255
|
mime: util.MimeTypes[];
|
|
256
256
|
}
|
|
257
|
-
export interface $ZodCheckMimeTypeInternals<T extends File = File> extends $ZodCheckInternals<T> {
|
|
257
|
+
export interface $ZodCheckMimeTypeInternals<T extends schemas.File = schemas.File> extends $ZodCheckInternals<T> {
|
|
258
258
|
def: $ZodCheckMimeTypeDef;
|
|
259
259
|
issc: errors.$ZodIssueInvalidValue;
|
|
260
260
|
}
|
|
261
|
-
export interface $ZodCheckMimeType<T extends File = File> extends $ZodCheck<T> {
|
|
261
|
+
export interface $ZodCheckMimeType<T extends schemas.File = schemas.File> extends $ZodCheck<T> {
|
|
262
262
|
_zod: $ZodCheckMimeTypeInternals<T>;
|
|
263
263
|
}
|
|
264
264
|
export declare const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType>;
|
package/v4/core/checks.d.ts
CHANGED
|
@@ -254,11 +254,11 @@ export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
|
|
|
254
254
|
check: "mime_type";
|
|
255
255
|
mime: util.MimeTypes[];
|
|
256
256
|
}
|
|
257
|
-
export interface $ZodCheckMimeTypeInternals<T extends File = File> extends $ZodCheckInternals<T> {
|
|
257
|
+
export interface $ZodCheckMimeTypeInternals<T extends schemas.File = schemas.File> extends $ZodCheckInternals<T> {
|
|
258
258
|
def: $ZodCheckMimeTypeDef;
|
|
259
259
|
issc: errors.$ZodIssueInvalidValue;
|
|
260
260
|
}
|
|
261
|
-
export interface $ZodCheckMimeType<T extends File = File> extends $ZodCheck<T> {
|
|
261
|
+
export interface $ZodCheckMimeType<T extends schemas.File = schemas.File> extends $ZodCheck<T> {
|
|
262
262
|
_zod: $ZodCheckMimeTypeInternals<T>;
|
|
263
263
|
}
|
|
264
264
|
export declare const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType>;
|
package/v4/core/errors.cjs
CHANGED
|
@@ -41,13 +41,7 @@ const initializer = (inst, def) => {
|
|
|
41
41
|
value: def,
|
|
42
42
|
enumerable: false,
|
|
43
43
|
});
|
|
44
|
-
|
|
45
|
-
get() {
|
|
46
|
-
return JSON.stringify(def, util.jsonStringifyReplacer, 2);
|
|
47
|
-
},
|
|
48
|
-
enumerable: true,
|
|
49
|
-
// configurable: false,
|
|
50
|
-
});
|
|
44
|
+
inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);
|
|
51
45
|
Object.defineProperty(inst, "toString", {
|
|
52
46
|
value: () => inst.message,
|
|
53
47
|
enumerable: false,
|
|
@@ -194,8 +188,9 @@ function treeifyError(error, _mapper) {
|
|
|
194
188
|
* ✖ Invalid input: expected number
|
|
195
189
|
* ```
|
|
196
190
|
*/
|
|
197
|
-
function toDotPath(
|
|
191
|
+
function toDotPath(_path) {
|
|
198
192
|
const segs = [];
|
|
193
|
+
const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
|
|
199
194
|
for (const seg of path) {
|
|
200
195
|
if (typeof seg === "number")
|
|
201
196
|
segs.push(`[${seg}]`);
|
|
@@ -214,7 +209,7 @@ function toDotPath(path) {
|
|
|
214
209
|
function prettifyError(error) {
|
|
215
210
|
const lines = [];
|
|
216
211
|
// sort by path length
|
|
217
|
-
const issues = [...error.issues].sort((a, b) => a.path.length - b.path.length);
|
|
212
|
+
const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
218
213
|
// Process each issue
|
|
219
214
|
for (const issue of issues) {
|
|
220
215
|
lines.push(`✖ ${issue.message}`);
|
package/v4/core/errors.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { $ZodCheck, $ZodStringFormats } from "./checks.cjs";
|
|
2
2
|
import { $constructor } from "./core.cjs";
|
|
3
3
|
import type { $ZodType } from "./schemas.cjs";
|
|
4
|
+
import type { StandardSchemaV1 } from "./standard-schema.cjs";
|
|
4
5
|
import * as util from "./util.cjs";
|
|
5
6
|
export interface $ZodIssueBase {
|
|
6
7
|
readonly code?: string;
|
|
@@ -107,7 +108,7 @@ type RawIssue<T extends $ZodIssueBase> = util.Flatten<util.MakePartial<T, "messa
|
|
|
107
108
|
readonly input?: unknown;
|
|
108
109
|
/** The schema or check that originated this issue. */
|
|
109
110
|
readonly inst?: $ZodType | $ZodCheck;
|
|
110
|
-
/**
|
|
111
|
+
/** If `true`, Zod will continue executing validation despite this issue. */
|
|
111
112
|
readonly continue?: boolean | undefined;
|
|
112
113
|
} & Record<string, any>>;
|
|
113
114
|
export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
|
|
@@ -202,9 +203,6 @@ export declare function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue:
|
|
|
202
203
|
* ✖ Invalid input: expected number
|
|
203
204
|
* ```
|
|
204
205
|
*/
|
|
205
|
-
export declare function toDotPath(
|
|
206
|
-
|
|
207
|
-
issues: $ZodIssueBase[];
|
|
208
|
-
}
|
|
209
|
-
export declare function prettifyError(error: BaseError): string;
|
|
206
|
+
export declare function toDotPath(_path: readonly (string | number | symbol | StandardSchemaV1.PathSegment)[]): string;
|
|
207
|
+
export declare function prettifyError(error: StandardSchemaV1.FailureResult): string;
|
|
210
208
|
export {};
|
package/v4/core/errors.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { $ZodCheck, $ZodStringFormats } from "./checks.js";
|
|
2
2
|
import { $constructor } from "./core.js";
|
|
3
3
|
import type { $ZodType } from "./schemas.js";
|
|
4
|
+
import type { StandardSchemaV1 } from "./standard-schema.js";
|
|
4
5
|
import * as util from "./util.js";
|
|
5
6
|
export interface $ZodIssueBase {
|
|
6
7
|
readonly code?: string;
|
|
@@ -107,7 +108,7 @@ type RawIssue<T extends $ZodIssueBase> = util.Flatten<util.MakePartial<T, "messa
|
|
|
107
108
|
readonly input?: unknown;
|
|
108
109
|
/** The schema or check that originated this issue. */
|
|
109
110
|
readonly inst?: $ZodType | $ZodCheck;
|
|
110
|
-
/**
|
|
111
|
+
/** If `true`, Zod will continue executing validation despite this issue. */
|
|
111
112
|
readonly continue?: boolean | undefined;
|
|
112
113
|
} & Record<string, any>>;
|
|
113
114
|
export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
|
|
@@ -202,9 +203,6 @@ export declare function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue:
|
|
|
202
203
|
* ✖ Invalid input: expected number
|
|
203
204
|
* ```
|
|
204
205
|
*/
|
|
205
|
-
export declare function toDotPath(
|
|
206
|
-
|
|
207
|
-
issues: $ZodIssueBase[];
|
|
208
|
-
}
|
|
209
|
-
export declare function prettifyError(error: BaseError): string;
|
|
206
|
+
export declare function toDotPath(_path: readonly (string | number | symbol | StandardSchemaV1.PathSegment)[]): string;
|
|
207
|
+
export declare function prettifyError(error: StandardSchemaV1.FailureResult): string;
|
|
210
208
|
export {};
|
package/v4/core/errors.js
CHANGED
|
@@ -10,13 +10,7 @@ const initializer = (inst, def) => {
|
|
|
10
10
|
value: def,
|
|
11
11
|
enumerable: false,
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
get() {
|
|
15
|
-
return JSON.stringify(def, util.jsonStringifyReplacer, 2);
|
|
16
|
-
},
|
|
17
|
-
enumerable: true,
|
|
18
|
-
// configurable: false,
|
|
19
|
-
});
|
|
13
|
+
inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);
|
|
20
14
|
Object.defineProperty(inst, "toString", {
|
|
21
15
|
value: () => inst.message,
|
|
22
16
|
enumerable: false,
|
|
@@ -163,8 +157,9 @@ export function treeifyError(error, _mapper) {
|
|
|
163
157
|
* ✖ Invalid input: expected number
|
|
164
158
|
* ```
|
|
165
159
|
*/
|
|
166
|
-
export function toDotPath(
|
|
160
|
+
export function toDotPath(_path) {
|
|
167
161
|
const segs = [];
|
|
162
|
+
const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
|
|
168
163
|
for (const seg of path) {
|
|
169
164
|
if (typeof seg === "number")
|
|
170
165
|
segs.push(`[${seg}]`);
|
|
@@ -183,7 +178,7 @@ export function toDotPath(path) {
|
|
|
183
178
|
export function prettifyError(error) {
|
|
184
179
|
const lines = [];
|
|
185
180
|
// sort by path length
|
|
186
|
-
const issues = [...error.issues].sort((a, b) => a.path.length - b.path.length);
|
|
181
|
+
const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
187
182
|
// Process each issue
|
|
188
183
|
for (const issue of issues) {
|
|
189
184
|
lines.push(`✖ ${issue.message}`);
|
package/v4/core/regexes.cjs
CHANGED
|
@@ -16,7 +16,7 @@ exports.duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\
|
|
|
16
16
|
exports.extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
17
17
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
18
18
|
exports.guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
19
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
19
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
20
20
|
*
|
|
21
21
|
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
22
22
|
const uuid = (version) => {
|
package/v4/core/regexes.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const duration: RegExp;
|
|
|
10
10
|
export declare const extendedDuration: RegExp;
|
|
11
11
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
12
12
|
export declare const guid: RegExp;
|
|
13
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
13
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
14
14
|
*
|
|
15
15
|
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
16
16
|
export declare const uuid: (version?: number | undefined) => RegExp;
|
package/v4/core/regexes.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const duration: RegExp;
|
|
|
10
10
|
export declare const extendedDuration: RegExp;
|
|
11
11
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
12
12
|
export declare const guid: RegExp;
|
|
13
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
13
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
14
14
|
*
|
|
15
15
|
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
16
16
|
export declare const uuid: (version?: number | undefined) => RegExp;
|
package/v4/core/regexes.js
CHANGED
|
@@ -10,7 +10,7 @@ export const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=
|
|
|
10
10
|
export const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
11
11
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
12
12
|
export const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
13
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
13
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
14
14
|
*
|
|
15
15
|
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
16
16
|
export const uuid = (version) => {
|
package/v4/core/registries.cjs
CHANGED
|
@@ -40,7 +40,8 @@ class $ZodRegistry {
|
|
|
40
40
|
if (p) {
|
|
41
41
|
const pm = { ...(this.get(p) ?? {}) };
|
|
42
42
|
delete pm.id; // do not inherit id
|
|
43
|
-
|
|
43
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
44
|
+
return Object.keys(f).length ? f : undefined;
|
|
44
45
|
}
|
|
45
46
|
return this._map.get(schema);
|
|
46
47
|
}
|
package/v4/core/registries.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.out
|
|
|
9
9
|
}) => $replace<R, S> : Meta extends object ? {
|
|
10
10
|
[K in keyof Meta]: $replace<Meta[K], S>;
|
|
11
11
|
} : Meta;
|
|
12
|
-
type MetadataType =
|
|
12
|
+
type MetadataType = object | undefined;
|
|
13
13
|
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
|
14
14
|
_meta: Meta;
|
|
15
15
|
_schema: Schema;
|
package/v4/core/registries.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.out
|
|
|
9
9
|
}) => $replace<R, S> : Meta extends object ? {
|
|
10
10
|
[K in keyof Meta]: $replace<Meta[K], S>;
|
|
11
11
|
} : Meta;
|
|
12
|
-
type MetadataType =
|
|
12
|
+
type MetadataType = object | undefined;
|
|
13
13
|
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
|
14
14
|
_meta: Meta;
|
|
15
15
|
_schema: Schema;
|
package/v4/core/registries.js
CHANGED
|
@@ -36,7 +36,8 @@ export class $ZodRegistry {
|
|
|
36
36
|
if (p) {
|
|
37
37
|
const pm = { ...(this.get(p) ?? {}) };
|
|
38
38
|
delete pm.id; // do not inherit id
|
|
39
|
-
|
|
39
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
40
|
+
return Object.keys(f).length ? f : undefined;
|
|
40
41
|
}
|
|
41
42
|
return this._map.get(schema);
|
|
42
43
|
}
|