zod 4.0.10 → 4.0.12
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 +11 -8
- package/src/v4/classic/checks.ts +1 -0
- package/src/v4/classic/schemas.ts +12 -28
- package/src/v4/classic/tests/datetime.test.ts +6 -0
- package/src/v4/classic/tests/number.test.ts +23 -0
- package/src/v4/classic/tests/recursive-types.test.ts +39 -0
- package/src/v4/classic/tests/string.test.ts +38 -0
- package/src/v4/classic/tests/tuple.test.ts +2 -2
- package/src/v4/core/api.ts +51 -7
- package/src/v4/core/checks.ts +2 -0
- package/src/v4/core/errors.ts +26 -23
- package/src/v4/core/regexes.ts +7 -4
- package/src/v4/core/schemas.ts +41 -4
- package/src/v4/core/util.ts +11 -1
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/locales/index.ts +1 -0
- package/src/v4/locales/yo.ts +131 -0
- package/src/v4/mini/schemas.ts +11 -0
- package/v3/locales/en.cjs +1 -0
- package/v3/locales/en.d.cts +1 -1
- package/v4/classic/checks.d.cts +1 -1
- package/v4/classic/checks.d.ts +1 -1
- package/v4/classic/schemas.cjs +5 -20
- package/v4/classic/schemas.d.cts +5 -7
- package/v4/classic/schemas.d.ts +5 -7
- package/v4/classic/schemas.js +4 -20
- package/v4/core/api.cjs +33 -7
- package/v4/core/api.d.cts +12 -0
- package/v4/core/api.d.ts +12 -0
- package/v4/core/api.js +31 -7
- package/v4/core/checks.cjs +2 -0
- package/v4/core/checks.js +2 -0
- package/v4/core/errors.d.cts +17 -16
- package/v4/core/errors.d.ts +17 -16
- package/v4/core/regexes.cjs +6 -5
- package/v4/core/regexes.d.cts +1 -0
- package/v4/core/regexes.d.ts +1 -0
- package/v4/core/regexes.js +5 -4
- package/v4/core/schemas.cjs +8 -3
- package/v4/core/schemas.d.cts +3 -1
- package/v4/core/schemas.d.ts +3 -1
- package/v4/core/schemas.js +8 -3
- package/v4/core/util.cjs +9 -1
- package/v4/core/util.js +9 -1
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
- package/v4/locales/ar.cjs +1 -0
- package/v4/locales/ar.d.cts +2 -1
- package/v4/locales/az.cjs +1 -0
- package/v4/locales/az.d.cts +2 -1
- package/v4/locales/be.cjs +1 -0
- package/v4/locales/be.d.cts +2 -1
- package/v4/locales/ca.cjs +1 -0
- package/v4/locales/ca.d.cts +2 -1
- package/v4/locales/cs.cjs +1 -0
- package/v4/locales/cs.d.cts +2 -1
- package/v4/locales/da.cjs +1 -0
- package/v4/locales/da.d.cts +2 -1
- package/v4/locales/de.cjs +1 -0
- package/v4/locales/de.d.cts +2 -1
- package/v4/locales/es.cjs +1 -0
- package/v4/locales/es.d.cts +2 -1
- package/v4/locales/fa.cjs +1 -0
- package/v4/locales/fa.d.cts +2 -1
- package/v4/locales/fi.cjs +1 -0
- package/v4/locales/fi.d.cts +2 -1
- package/v4/locales/fr-CA.cjs +1 -0
- package/v4/locales/fr-CA.d.cts +2 -1
- package/v4/locales/fr.cjs +1 -0
- package/v4/locales/fr.d.cts +2 -1
- package/v4/locales/he.cjs +1 -0
- package/v4/locales/he.d.cts +2 -1
- package/v4/locales/hu.cjs +1 -0
- package/v4/locales/hu.d.cts +2 -1
- package/v4/locales/id.cjs +1 -0
- package/v4/locales/id.d.cts +2 -1
- 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/locales/it.cjs +1 -0
- package/v4/locales/it.d.cts +2 -1
- package/v4/locales/ja.cjs +1 -0
- package/v4/locales/ja.d.cts +2 -1
- package/v4/locales/kh.cjs +1 -0
- package/v4/locales/kh.d.cts +2 -1
- package/v4/locales/ko.cjs +1 -0
- package/v4/locales/ko.d.cts +2 -1
- package/v4/locales/mk.cjs +1 -0
- package/v4/locales/mk.d.cts +2 -1
- package/v4/locales/ms.cjs +1 -0
- package/v4/locales/ms.d.cts +2 -1
- package/v4/locales/nl.cjs +1 -0
- package/v4/locales/nl.d.cts +2 -1
- package/v4/locales/no.cjs +1 -0
- package/v4/locales/no.d.cts +2 -1
- package/v4/locales/ota.cjs +1 -0
- package/v4/locales/ota.d.cts +2 -1
- package/v4/locales/pl.cjs +1 -0
- package/v4/locales/pl.d.cts +2 -1
- package/v4/locales/ps.cjs +1 -0
- package/v4/locales/ps.d.cts +2 -1
- package/v4/locales/pt.cjs +1 -0
- package/v4/locales/pt.d.cts +2 -1
- package/v4/locales/ru.cjs +1 -0
- package/v4/locales/ru.d.cts +2 -1
- package/v4/locales/sl.cjs +1 -0
- package/v4/locales/sl.d.cts +2 -1
- package/v4/locales/sv.cjs +1 -0
- package/v4/locales/sv.d.cts +2 -1
- package/v4/locales/ta.cjs +1 -0
- package/v4/locales/ta.d.cts +2 -1
- package/v4/locales/th.cjs +1 -0
- package/v4/locales/th.d.cts +2 -1
- package/v4/locales/ua.cjs +1 -0
- package/v4/locales/ua.d.cts +2 -1
- package/v4/locales/ur.cjs +1 -0
- package/v4/locales/ur.d.cts +2 -1
- package/v4/locales/vi.cjs +1 -0
- package/v4/locales/vi.d.cts +2 -1
- package/v4/locales/yo.cjs +142 -0
- package/v4/locales/yo.d.cts +5 -0
- package/v4/locales/yo.d.ts +4 -0
- package/v4/locales/yo.js +115 -0
- package/v4/locales/zh-CN.cjs +1 -0
- package/v4/locales/zh-CN.d.cts +2 -1
- package/v4/locales/zh-TW.cjs +1 -0
- package/v4/locales/zh-TW.d.cts +2 -1
- package/v4/mini/schemas.cjs +9 -0
- package/v4/mini/schemas.d.cts +2 -0
- package/v4/mini/schemas.d.ts +2 -0
- package/v4/mini/schemas.js +7 -0
package/v4/classic/schemas.js
CHANGED
|
@@ -308,6 +308,9 @@ export const ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("ZodCustomS
|
|
|
308
308
|
export function stringFormat(format, fnOrRegex, _params = {}) {
|
|
309
309
|
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
310
310
|
}
|
|
311
|
+
export function hostname(_params) {
|
|
312
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
313
|
+
}
|
|
311
314
|
export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
|
|
312
315
|
core.$ZodNumber.init(inst, def);
|
|
313
316
|
ZodType.init(inst, def);
|
|
@@ -953,26 +956,7 @@ export function refine(fn, _params = {}) {
|
|
|
953
956
|
}
|
|
954
957
|
// superRefine
|
|
955
958
|
export function superRefine(fn) {
|
|
956
|
-
|
|
957
|
-
payload.addIssue = (issue) => {
|
|
958
|
-
if (typeof issue === "string") {
|
|
959
|
-
payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
// for Zod 3 backwards compatibility
|
|
963
|
-
const _issue = issue;
|
|
964
|
-
if (_issue.fatal)
|
|
965
|
-
_issue.continue = false;
|
|
966
|
-
_issue.code ?? (_issue.code = "custom");
|
|
967
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
968
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
969
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
970
|
-
payload.issues.push(util.issue(_issue));
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
return fn(payload.value, payload);
|
|
974
|
-
});
|
|
975
|
-
return ch;
|
|
959
|
+
return core._superRefine(fn);
|
|
976
960
|
}
|
|
977
961
|
function _instanceof(cls, params = {
|
|
978
962
|
error: `Input not instance of ${cls.name}`,
|
package/v4/core/api.cjs
CHANGED
|
@@ -135,6 +135,8 @@ exports._lazy = _lazy;
|
|
|
135
135
|
exports._promise = _promise;
|
|
136
136
|
exports._custom = _custom;
|
|
137
137
|
exports._refine = _refine;
|
|
138
|
+
exports._superRefine = _superRefine;
|
|
139
|
+
exports._check = _check;
|
|
138
140
|
exports._stringbool = _stringbool;
|
|
139
141
|
exports._stringFormat = _stringFormat;
|
|
140
142
|
const checks = __importStar(require("./checks.cjs"));
|
|
@@ -947,13 +949,6 @@ function _custom(Class, fn, _params) {
|
|
|
947
949
|
});
|
|
948
950
|
return schema;
|
|
949
951
|
}
|
|
950
|
-
// export function _refine<T>(
|
|
951
|
-
// Class: util.SchemaClass<schemas.$ZodCustom>,
|
|
952
|
-
// fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
|
|
953
|
-
// _params: string | $ZodCustomParams = {}
|
|
954
|
-
// ): checks.$ZodCheck<T> {
|
|
955
|
-
// return _custom(Class, fn, _params);
|
|
956
|
-
// }
|
|
957
952
|
// same as _custom but defaults to abort:false
|
|
958
953
|
function _refine(Class, fn, _params) {
|
|
959
954
|
const schema = new Class({
|
|
@@ -964,6 +959,36 @@ function _refine(Class, fn, _params) {
|
|
|
964
959
|
});
|
|
965
960
|
return schema;
|
|
966
961
|
}
|
|
962
|
+
function _superRefine(fn) {
|
|
963
|
+
const ch = _check((payload) => {
|
|
964
|
+
payload.addIssue = (issue) => {
|
|
965
|
+
if (typeof issue === "string") {
|
|
966
|
+
payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
// for Zod 3 backwards compatibility
|
|
970
|
+
const _issue = issue;
|
|
971
|
+
if (_issue.fatal)
|
|
972
|
+
_issue.continue = false;
|
|
973
|
+
_issue.code ?? (_issue.code = "custom");
|
|
974
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
975
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
976
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
977
|
+
payload.issues.push(util.issue(_issue));
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
return fn(payload.value, payload);
|
|
981
|
+
});
|
|
982
|
+
return ch;
|
|
983
|
+
}
|
|
984
|
+
function _check(fn, params) {
|
|
985
|
+
const ch = new checks.$ZodCheck({
|
|
986
|
+
check: "custom",
|
|
987
|
+
...util.normalizeParams(params),
|
|
988
|
+
});
|
|
989
|
+
ch._zod.check = fn;
|
|
990
|
+
return ch;
|
|
991
|
+
}
|
|
967
992
|
function _stringbool(Classes, _params) {
|
|
968
993
|
const params = util.normalizeParams(_params);
|
|
969
994
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -997,6 +1022,7 @@ function _stringbool(Classes, _params) {
|
|
|
997
1022
|
values: [...truthySet, ...falsySet],
|
|
998
1023
|
input: payload.value,
|
|
999
1024
|
inst: tx,
|
|
1025
|
+
continue: false,
|
|
1000
1026
|
});
|
|
1001
1027
|
return {};
|
|
1002
1028
|
}
|
package/v4/core/api.d.cts
CHANGED
|
@@ -265,6 +265,18 @@ export declare function _promise<T extends schemas.$ZodObject>(Class: util.Schem
|
|
|
265
265
|
export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">;
|
|
266
266
|
export declare function _custom<O = unknown, I = O>(Class: util.SchemaClass<schemas.$ZodCustom>, fn: (data: O) => unknown, _params: string | $ZodCustomParams | undefined): schemas.$ZodCustom<O, I>;
|
|
267
267
|
export declare function _refine<O = unknown, I = O>(Class: util.SchemaClass<schemas.$ZodCustom>, fn: (data: O) => unknown, _params: string | $ZodCustomParams | undefined): schemas.$ZodCustom<O, I>;
|
|
268
|
+
export type $ZodSuperRefineIssue<T extends errors.$ZodIssueBase = errors.$ZodIssue> = T extends any ? RawIssue<T> : never;
|
|
269
|
+
type RawIssue<T extends errors.$ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
270
|
+
/** The schema or check that originated this issue. */
|
|
271
|
+
readonly inst?: schemas.$ZodType | checks.$ZodCheck;
|
|
272
|
+
/** If `true`, Zod will continue executing checks/refinements after this issue. */
|
|
273
|
+
readonly continue?: boolean | undefined;
|
|
274
|
+
} & Record<string, unknown>> : never;
|
|
275
|
+
export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
|
|
276
|
+
addIssue(arg: string | $ZodSuperRefineIssue): void;
|
|
277
|
+
}
|
|
278
|
+
export declare function _superRefine<T>(fn: (arg: T, payload: $RefinementCtx<T>) => void | Promise<void>): checks.$ZodCheck<T>;
|
|
279
|
+
export declare function _check<O = unknown>(fn: schemas.CheckFn<O>, params?: string | $ZodCustomParams): checks.$ZodCheck<O>;
|
|
268
280
|
export interface $ZodStringBoolParams extends TypeParams {
|
|
269
281
|
truthy?: string[];
|
|
270
282
|
falsy?: string[];
|
package/v4/core/api.d.ts
CHANGED
|
@@ -265,6 +265,18 @@ export declare function _promise<T extends schemas.$ZodObject>(Class: util.Schem
|
|
|
265
265
|
export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">;
|
|
266
266
|
export declare function _custom<O = unknown, I = O>(Class: util.SchemaClass<schemas.$ZodCustom>, fn: (data: O) => unknown, _params: string | $ZodCustomParams | undefined): schemas.$ZodCustom<O, I>;
|
|
267
267
|
export declare function _refine<O = unknown, I = O>(Class: util.SchemaClass<schemas.$ZodCustom>, fn: (data: O) => unknown, _params: string | $ZodCustomParams | undefined): schemas.$ZodCustom<O, I>;
|
|
268
|
+
export type $ZodSuperRefineIssue<T extends errors.$ZodIssueBase = errors.$ZodIssue> = T extends any ? RawIssue<T> : never;
|
|
269
|
+
type RawIssue<T extends errors.$ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
270
|
+
/** The schema or check that originated this issue. */
|
|
271
|
+
readonly inst?: schemas.$ZodType | checks.$ZodCheck;
|
|
272
|
+
/** If `true`, Zod will continue executing checks/refinements after this issue. */
|
|
273
|
+
readonly continue?: boolean | undefined;
|
|
274
|
+
} & Record<string, unknown>> : never;
|
|
275
|
+
export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
|
|
276
|
+
addIssue(arg: string | $ZodSuperRefineIssue): void;
|
|
277
|
+
}
|
|
278
|
+
export declare function _superRefine<T>(fn: (arg: T, payload: $RefinementCtx<T>) => void | Promise<void>): checks.$ZodCheck<T>;
|
|
279
|
+
export declare function _check<O = unknown>(fn: schemas.CheckFn<O>, params?: string | $ZodCustomParams): checks.$ZodCheck<O>;
|
|
268
280
|
export interface $ZodStringBoolParams extends TypeParams {
|
|
269
281
|
truthy?: string[];
|
|
270
282
|
falsy?: string[];
|
package/v4/core/api.js
CHANGED
|
@@ -814,13 +814,6 @@ export function _custom(Class, fn, _params) {
|
|
|
814
814
|
});
|
|
815
815
|
return schema;
|
|
816
816
|
}
|
|
817
|
-
// export function _refine<T>(
|
|
818
|
-
// Class: util.SchemaClass<schemas.$ZodCustom>,
|
|
819
|
-
// fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
|
|
820
|
-
// _params: string | $ZodCustomParams = {}
|
|
821
|
-
// ): checks.$ZodCheck<T> {
|
|
822
|
-
// return _custom(Class, fn, _params);
|
|
823
|
-
// }
|
|
824
817
|
// same as _custom but defaults to abort:false
|
|
825
818
|
export function _refine(Class, fn, _params) {
|
|
826
819
|
const schema = new Class({
|
|
@@ -831,6 +824,36 @@ export function _refine(Class, fn, _params) {
|
|
|
831
824
|
});
|
|
832
825
|
return schema;
|
|
833
826
|
}
|
|
827
|
+
export function _superRefine(fn) {
|
|
828
|
+
const ch = _check((payload) => {
|
|
829
|
+
payload.addIssue = (issue) => {
|
|
830
|
+
if (typeof issue === "string") {
|
|
831
|
+
payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
// for Zod 3 backwards compatibility
|
|
835
|
+
const _issue = issue;
|
|
836
|
+
if (_issue.fatal)
|
|
837
|
+
_issue.continue = false;
|
|
838
|
+
_issue.code ?? (_issue.code = "custom");
|
|
839
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
840
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
841
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
842
|
+
payload.issues.push(util.issue(_issue));
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
return fn(payload.value, payload);
|
|
846
|
+
});
|
|
847
|
+
return ch;
|
|
848
|
+
}
|
|
849
|
+
export function _check(fn, params) {
|
|
850
|
+
const ch = new checks.$ZodCheck({
|
|
851
|
+
check: "custom",
|
|
852
|
+
...util.normalizeParams(params),
|
|
853
|
+
});
|
|
854
|
+
ch._zod.check = fn;
|
|
855
|
+
return ch;
|
|
856
|
+
}
|
|
834
857
|
export function _stringbool(Classes, _params) {
|
|
835
858
|
const params = util.normalizeParams(_params);
|
|
836
859
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -864,6 +887,7 @@ export function _stringbool(Classes, _params) {
|
|
|
864
887
|
values: [...truthySet, ...falsySet],
|
|
865
888
|
input: payload.value,
|
|
866
889
|
inst: tx,
|
|
890
|
+
continue: false,
|
|
867
891
|
});
|
|
868
892
|
return {};
|
|
869
893
|
}
|
package/v4/core/checks.cjs
CHANGED
|
@@ -151,6 +151,7 @@ exports.$ZodCheckNumberFormat = core.$constructor("$ZodCheckNumberFormat", (inst
|
|
|
151
151
|
expected: origin,
|
|
152
152
|
format: def.format,
|
|
153
153
|
code: "invalid_type",
|
|
154
|
+
continue: false,
|
|
154
155
|
input,
|
|
155
156
|
inst,
|
|
156
157
|
});
|
|
@@ -580,6 +581,7 @@ exports.$ZodCheckMimeType = core.$constructor("$ZodCheckMimeType", (inst, def) =
|
|
|
580
581
|
values: def.mime,
|
|
581
582
|
input: payload.value.type,
|
|
582
583
|
inst,
|
|
584
|
+
continue: !def.abort,
|
|
583
585
|
});
|
|
584
586
|
};
|
|
585
587
|
});
|
package/v4/core/checks.js
CHANGED
|
@@ -125,6 +125,7 @@ export const $ZodCheckNumberFormat = /*@__PURE__*/ core.$constructor("$ZodCheckN
|
|
|
125
125
|
expected: origin,
|
|
126
126
|
format: def.format,
|
|
127
127
|
code: "invalid_type",
|
|
128
|
+
continue: false,
|
|
128
129
|
input,
|
|
129
130
|
inst,
|
|
130
131
|
});
|
|
@@ -554,6 +555,7 @@ export const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor("$ZodCheckMimeT
|
|
|
554
555
|
values: def.mime,
|
|
555
556
|
input: payload.value.type,
|
|
556
557
|
inst,
|
|
558
|
+
continue: !def.abort,
|
|
557
559
|
});
|
|
558
560
|
};
|
|
559
561
|
});
|
package/v4/core/errors.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ export interface $ZodIssueBase {
|
|
|
12
12
|
export interface $ZodIssueInvalidType<Input = unknown> extends $ZodIssueBase {
|
|
13
13
|
readonly code: "invalid_type";
|
|
14
14
|
readonly expected: $ZodType["_zod"]["def"]["type"];
|
|
15
|
-
readonly input
|
|
15
|
+
readonly input?: Input;
|
|
16
16
|
}
|
|
17
17
|
export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
|
|
18
18
|
readonly code: "too_big";
|
|
@@ -20,7 +20,7 @@ export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
|
|
|
20
20
|
readonly maximum: number | bigint;
|
|
21
21
|
readonly inclusive?: boolean;
|
|
22
22
|
readonly exact?: boolean;
|
|
23
|
-
readonly input
|
|
23
|
+
readonly input?: Input;
|
|
24
24
|
}
|
|
25
25
|
export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
|
|
26
26
|
readonly code: "too_small";
|
|
@@ -30,52 +30,52 @@ export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
|
|
|
30
30
|
readonly inclusive?: boolean;
|
|
31
31
|
/** True if the allowed value is fixed (e.g.` z.length(5)`), not a range (`z.minLength(5)`) */
|
|
32
32
|
readonly exact?: boolean;
|
|
33
|
-
readonly input
|
|
33
|
+
readonly input?: Input;
|
|
34
34
|
}
|
|
35
35
|
export interface $ZodIssueInvalidStringFormat extends $ZodIssueBase {
|
|
36
36
|
readonly code: "invalid_format";
|
|
37
37
|
readonly format: $ZodStringFormats | (string & {});
|
|
38
38
|
readonly pattern?: string;
|
|
39
|
-
readonly input
|
|
39
|
+
readonly input?: string;
|
|
40
40
|
}
|
|
41
41
|
export interface $ZodIssueNotMultipleOf<Input extends number | bigint = number | bigint> extends $ZodIssueBase {
|
|
42
42
|
readonly code: "not_multiple_of";
|
|
43
43
|
readonly divisor: number;
|
|
44
|
-
readonly input
|
|
44
|
+
readonly input?: Input;
|
|
45
45
|
}
|
|
46
46
|
export interface $ZodIssueUnrecognizedKeys extends $ZodIssueBase {
|
|
47
47
|
readonly code: "unrecognized_keys";
|
|
48
48
|
readonly keys: string[];
|
|
49
|
-
readonly input
|
|
49
|
+
readonly input?: Record<string, unknown>;
|
|
50
50
|
}
|
|
51
51
|
export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
|
|
52
52
|
readonly code: "invalid_union";
|
|
53
53
|
readonly errors: $ZodIssue[][];
|
|
54
|
-
readonly input
|
|
54
|
+
readonly input?: unknown;
|
|
55
55
|
readonly discriminator?: string | undefined;
|
|
56
56
|
}
|
|
57
57
|
export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
|
58
58
|
readonly code: "invalid_key";
|
|
59
59
|
readonly origin: "map" | "record";
|
|
60
60
|
readonly issues: $ZodIssue[];
|
|
61
|
-
readonly input
|
|
61
|
+
readonly input?: Input;
|
|
62
62
|
}
|
|
63
63
|
export interface $ZodIssueInvalidElement<Input = unknown> extends $ZodIssueBase {
|
|
64
64
|
readonly code: "invalid_element";
|
|
65
65
|
readonly origin: "map" | "set";
|
|
66
66
|
readonly key: unknown;
|
|
67
67
|
readonly issues: $ZodIssue[];
|
|
68
|
-
readonly input
|
|
68
|
+
readonly input?: Input;
|
|
69
69
|
}
|
|
70
70
|
export interface $ZodIssueInvalidValue<Input = unknown> extends $ZodIssueBase {
|
|
71
71
|
readonly code: "invalid_value";
|
|
72
72
|
readonly values: util.Primitive[];
|
|
73
|
-
readonly input
|
|
73
|
+
readonly input?: Input;
|
|
74
74
|
}
|
|
75
75
|
export interface $ZodIssueCustom extends $ZodIssueBase {
|
|
76
76
|
readonly code: "custom";
|
|
77
77
|
readonly params?: Record<string, any> | undefined;
|
|
78
|
-
readonly input
|
|
78
|
+
readonly input?: unknown;
|
|
79
79
|
}
|
|
80
80
|
export interface $ZodIssueStringCommonFormats extends $ZodIssueInvalidStringFormat {
|
|
81
81
|
format: Exclude<$ZodStringFormats, "regex" | "jwt" | "starts_with" | "ends_with" | "includes">;
|
|
@@ -103,15 +103,16 @@ export interface $ZodIssueStringIncludes extends $ZodIssueInvalidStringFormat {
|
|
|
103
103
|
export type $ZodStringFormatIssues = $ZodIssueStringCommonFormats | $ZodIssueStringInvalidRegex | $ZodIssueStringInvalidJWT | $ZodIssueStringStartsWith | $ZodIssueStringEndsWith | $ZodIssueStringIncludes;
|
|
104
104
|
export type $ZodIssue = $ZodIssueInvalidType | $ZodIssueTooBig | $ZodIssueTooSmall | $ZodIssueInvalidStringFormat | $ZodIssueNotMultipleOf | $ZodIssueUnrecognizedKeys | $ZodIssueInvalidUnion | $ZodIssueInvalidKey | $ZodIssueInvalidElement | $ZodIssueInvalidValue | $ZodIssueCustom;
|
|
105
105
|
export type $ZodIssueCode = $ZodIssue["code"];
|
|
106
|
-
export type $
|
|
107
|
-
type RawIssue<T extends $ZodIssueBase> = util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
106
|
+
export type $ZodInternalIssue<T extends $ZodIssueBase = $ZodIssue> = T extends any ? RawIssue<T> : never;
|
|
107
|
+
type RawIssue<T extends $ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
108
108
|
/** The input data */
|
|
109
|
-
readonly input
|
|
109
|
+
readonly input: unknown;
|
|
110
110
|
/** The schema or check that originated this issue. */
|
|
111
111
|
readonly inst?: $ZodType | $ZodCheck;
|
|
112
|
-
/** If `true`, Zod will continue executing
|
|
112
|
+
/** If `true`, Zod will continue executing checks/refinements after this issue. */
|
|
113
113
|
readonly continue?: boolean | undefined;
|
|
114
|
-
} & Record<string,
|
|
114
|
+
} & Record<string, unknown>> : never;
|
|
115
|
+
export type $ZodRawIssue<T extends $ZodIssueBase = $ZodIssue> = $ZodInternalIssue<T>;
|
|
115
116
|
export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
|
|
116
117
|
(issue: $ZodRawIssue<T>): {
|
|
117
118
|
message: string;
|
package/v4/core/errors.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface $ZodIssueBase {
|
|
|
12
12
|
export interface $ZodIssueInvalidType<Input = unknown> extends $ZodIssueBase {
|
|
13
13
|
readonly code: "invalid_type";
|
|
14
14
|
readonly expected: $ZodType["_zod"]["def"]["type"];
|
|
15
|
-
readonly input
|
|
15
|
+
readonly input?: Input;
|
|
16
16
|
}
|
|
17
17
|
export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
|
|
18
18
|
readonly code: "too_big";
|
|
@@ -20,7 +20,7 @@ export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
|
|
|
20
20
|
readonly maximum: number | bigint;
|
|
21
21
|
readonly inclusive?: boolean;
|
|
22
22
|
readonly exact?: boolean;
|
|
23
|
-
readonly input
|
|
23
|
+
readonly input?: Input;
|
|
24
24
|
}
|
|
25
25
|
export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
|
|
26
26
|
readonly code: "too_small";
|
|
@@ -30,52 +30,52 @@ export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
|
|
|
30
30
|
readonly inclusive?: boolean;
|
|
31
31
|
/** True if the allowed value is fixed (e.g.` z.length(5)`), not a range (`z.minLength(5)`) */
|
|
32
32
|
readonly exact?: boolean;
|
|
33
|
-
readonly input
|
|
33
|
+
readonly input?: Input;
|
|
34
34
|
}
|
|
35
35
|
export interface $ZodIssueInvalidStringFormat extends $ZodIssueBase {
|
|
36
36
|
readonly code: "invalid_format";
|
|
37
37
|
readonly format: $ZodStringFormats | (string & {});
|
|
38
38
|
readonly pattern?: string;
|
|
39
|
-
readonly input
|
|
39
|
+
readonly input?: string;
|
|
40
40
|
}
|
|
41
41
|
export interface $ZodIssueNotMultipleOf<Input extends number | bigint = number | bigint> extends $ZodIssueBase {
|
|
42
42
|
readonly code: "not_multiple_of";
|
|
43
43
|
readonly divisor: number;
|
|
44
|
-
readonly input
|
|
44
|
+
readonly input?: Input;
|
|
45
45
|
}
|
|
46
46
|
export interface $ZodIssueUnrecognizedKeys extends $ZodIssueBase {
|
|
47
47
|
readonly code: "unrecognized_keys";
|
|
48
48
|
readonly keys: string[];
|
|
49
|
-
readonly input
|
|
49
|
+
readonly input?: Record<string, unknown>;
|
|
50
50
|
}
|
|
51
51
|
export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
|
|
52
52
|
readonly code: "invalid_union";
|
|
53
53
|
readonly errors: $ZodIssue[][];
|
|
54
|
-
readonly input
|
|
54
|
+
readonly input?: unknown;
|
|
55
55
|
readonly discriminator?: string | undefined;
|
|
56
56
|
}
|
|
57
57
|
export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
|
58
58
|
readonly code: "invalid_key";
|
|
59
59
|
readonly origin: "map" | "record";
|
|
60
60
|
readonly issues: $ZodIssue[];
|
|
61
|
-
readonly input
|
|
61
|
+
readonly input?: Input;
|
|
62
62
|
}
|
|
63
63
|
export interface $ZodIssueInvalidElement<Input = unknown> extends $ZodIssueBase {
|
|
64
64
|
readonly code: "invalid_element";
|
|
65
65
|
readonly origin: "map" | "set";
|
|
66
66
|
readonly key: unknown;
|
|
67
67
|
readonly issues: $ZodIssue[];
|
|
68
|
-
readonly input
|
|
68
|
+
readonly input?: Input;
|
|
69
69
|
}
|
|
70
70
|
export interface $ZodIssueInvalidValue<Input = unknown> extends $ZodIssueBase {
|
|
71
71
|
readonly code: "invalid_value";
|
|
72
72
|
readonly values: util.Primitive[];
|
|
73
|
-
readonly input
|
|
73
|
+
readonly input?: Input;
|
|
74
74
|
}
|
|
75
75
|
export interface $ZodIssueCustom extends $ZodIssueBase {
|
|
76
76
|
readonly code: "custom";
|
|
77
77
|
readonly params?: Record<string, any> | undefined;
|
|
78
|
-
readonly input
|
|
78
|
+
readonly input?: unknown;
|
|
79
79
|
}
|
|
80
80
|
export interface $ZodIssueStringCommonFormats extends $ZodIssueInvalidStringFormat {
|
|
81
81
|
format: Exclude<$ZodStringFormats, "regex" | "jwt" | "starts_with" | "ends_with" | "includes">;
|
|
@@ -103,15 +103,16 @@ export interface $ZodIssueStringIncludes extends $ZodIssueInvalidStringFormat {
|
|
|
103
103
|
export type $ZodStringFormatIssues = $ZodIssueStringCommonFormats | $ZodIssueStringInvalidRegex | $ZodIssueStringInvalidJWT | $ZodIssueStringStartsWith | $ZodIssueStringEndsWith | $ZodIssueStringIncludes;
|
|
104
104
|
export type $ZodIssue = $ZodIssueInvalidType | $ZodIssueTooBig | $ZodIssueTooSmall | $ZodIssueInvalidStringFormat | $ZodIssueNotMultipleOf | $ZodIssueUnrecognizedKeys | $ZodIssueInvalidUnion | $ZodIssueInvalidKey | $ZodIssueInvalidElement | $ZodIssueInvalidValue | $ZodIssueCustom;
|
|
105
105
|
export type $ZodIssueCode = $ZodIssue["code"];
|
|
106
|
-
export type $
|
|
107
|
-
type RawIssue<T extends $ZodIssueBase> = util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
106
|
+
export type $ZodInternalIssue<T extends $ZodIssueBase = $ZodIssue> = T extends any ? RawIssue<T> : never;
|
|
107
|
+
type RawIssue<T extends $ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
|
108
108
|
/** The input data */
|
|
109
|
-
readonly input
|
|
109
|
+
readonly input: unknown;
|
|
110
110
|
/** The schema or check that originated this issue. */
|
|
111
111
|
readonly inst?: $ZodType | $ZodCheck;
|
|
112
|
-
/** If `true`, Zod will continue executing
|
|
112
|
+
/** If `true`, Zod will continue executing checks/refinements after this issue. */
|
|
113
113
|
readonly continue?: boolean | undefined;
|
|
114
|
-
} & Record<string,
|
|
114
|
+
} & Record<string, unknown>> : never;
|
|
115
|
+
export type $ZodRawIssue<T extends $ZodIssueBase = $ZodIssue> = $ZodInternalIssue<T>;
|
|
115
116
|
export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
|
|
116
117
|
(issue: $ZodRawIssue<T>): {
|
|
117
118
|
message: string;
|
package/v4/core/regexes.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uppercase = exports.lowercase = exports.undefined = exports.null = exports.boolean = exports.number = exports.integer = exports.bigint = exports.string = exports.date = exports.e164 = exports.domain = exports.hostname = exports.base64url = exports.base64 = exports.cidrv6 = exports.cidrv4 = exports.ipv6 = exports.ipv4 = exports.browserEmail = exports.unicodeEmail = exports.rfc5322Email = exports.html5Email = exports.email = exports.uuid7 = exports.uuid6 = exports.uuid4 = exports.uuid = exports.guid = exports.extendedDuration = exports.duration = exports.nanoid = exports.ksuid = exports.xid = exports.ulid = exports.cuid2 = exports.cuid = void 0;
|
|
3
|
+
exports.uppercase = exports.lowercase = exports.undefined = exports.null = exports.boolean = exports.number = exports.integer = exports.bigint = exports.string = exports.date = exports.e164 = exports.domain = exports.hostname = exports.base64url = exports.base64 = exports.cidrv6 = exports.cidrv4 = exports.ipv6 = exports.ipv4 = exports.browserEmail = exports.idnEmail = exports.unicodeEmail = exports.rfc5322Email = exports.html5Email = exports.email = exports.uuid7 = exports.uuid6 = exports.uuid4 = exports.uuid = exports.guid = exports.extendedDuration = exports.duration = exports.nanoid = exports.ksuid = exports.xid = exports.ulid = exports.cuid2 = exports.cuid = void 0;
|
|
4
4
|
exports.emoji = emoji;
|
|
5
5
|
exports.time = time;
|
|
6
6
|
exports.datetime = datetime;
|
|
@@ -36,6 +36,7 @@ exports.html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9
|
|
|
36
36
|
exports.rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
37
37
|
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
|
38
38
|
exports.unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
39
|
+
exports.idnEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
39
40
|
exports.browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
40
41
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
41
42
|
const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
@@ -50,9 +51,8 @@ exports.cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})
|
|
|
50
51
|
exports.base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
51
52
|
exports.base64url = /^[A-Za-z0-9_-]*$/;
|
|
52
53
|
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
|
53
|
-
// export const hostname: RegExp =
|
|
54
|
-
|
|
55
|
-
exports.hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
54
|
+
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
55
|
+
exports.hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
56
56
|
exports.domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
57
57
|
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
58
58
|
exports.e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
@@ -79,8 +79,9 @@ function datetime(args) {
|
|
|
79
79
|
const opts = ["Z"];
|
|
80
80
|
if (args.local)
|
|
81
81
|
opts.push("");
|
|
82
|
+
// if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
82
83
|
if (args.offset)
|
|
83
|
-
opts.push(`([+-]\\d
|
|
84
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
84
85
|
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
85
86
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
86
87
|
}
|
package/v4/core/regexes.d.cts
CHANGED
|
@@ -25,6 +25,7 @@ export declare const html5Email: RegExp;
|
|
|
25
25
|
export declare const rfc5322Email: RegExp;
|
|
26
26
|
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
|
27
27
|
export declare const unicodeEmail: RegExp;
|
|
28
|
+
export declare const idnEmail: RegExp;
|
|
28
29
|
export declare const browserEmail: RegExp;
|
|
29
30
|
export declare function emoji(): RegExp;
|
|
30
31
|
export declare const ipv4: RegExp;
|
package/v4/core/regexes.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare const html5Email: RegExp;
|
|
|
25
25
|
export declare const rfc5322Email: RegExp;
|
|
26
26
|
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
|
27
27
|
export declare const unicodeEmail: RegExp;
|
|
28
|
+
export declare const idnEmail: RegExp;
|
|
28
29
|
export declare const browserEmail: RegExp;
|
|
29
30
|
export declare function emoji(): RegExp;
|
|
30
31
|
export declare const ipv4: RegExp;
|
package/v4/core/regexes.js
CHANGED
|
@@ -29,6 +29,7 @@ export const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA
|
|
|
29
29
|
export const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
30
30
|
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
|
31
31
|
export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
32
|
+
export const idnEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
32
33
|
export const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
33
34
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
34
35
|
const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
@@ -43,9 +44,8 @@ export const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{
|
|
|
43
44
|
export const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
44
45
|
export const base64url = /^[A-Za-z0-9_-]*$/;
|
|
45
46
|
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
|
46
|
-
// export const hostname: RegExp =
|
|
47
|
-
|
|
48
|
-
export const hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
47
|
+
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
48
|
+
export const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
49
49
|
export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
50
50
|
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
51
51
|
export const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
@@ -72,8 +72,9 @@ export function datetime(args) {
|
|
|
72
72
|
const opts = ["Z"];
|
|
73
73
|
if (args.local)
|
|
74
74
|
opts.push("");
|
|
75
|
+
// if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
75
76
|
if (args.offset)
|
|
76
|
-
opts.push(`([+-]\\d
|
|
77
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
77
78
|
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
78
79
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
79
80
|
}
|
package/v4/core/schemas.cjs
CHANGED
|
@@ -892,7 +892,12 @@ exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
|
|
892
892
|
}
|
|
893
893
|
return undefined;
|
|
894
894
|
});
|
|
895
|
+
const single = def.options.length === 1;
|
|
896
|
+
const first = def.options[0]._zod.run;
|
|
895
897
|
inst._zod.parse = (payload, ctx) => {
|
|
898
|
+
if (single) {
|
|
899
|
+
return first(payload, ctx);
|
|
900
|
+
}
|
|
896
901
|
let async = false;
|
|
897
902
|
const results = [];
|
|
898
903
|
for (const option of def.options) {
|
|
@@ -1084,10 +1089,10 @@ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
|
|
|
1084
1089
|
const tooSmall = input.length < optStart - 1;
|
|
1085
1090
|
if (tooBig || tooSmall) {
|
|
1086
1091
|
payload.issues.push({
|
|
1092
|
+
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
|
1087
1093
|
input,
|
|
1088
1094
|
inst,
|
|
1089
1095
|
origin: "array",
|
|
1090
|
-
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
|
1091
1096
|
});
|
|
1092
1097
|
return payload;
|
|
1093
1098
|
}
|
|
@@ -1199,8 +1204,8 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1199
1204
|
}
|
|
1200
1205
|
if (keyResult.issues.length) {
|
|
1201
1206
|
payload.issues.push({
|
|
1202
|
-
origin: "record",
|
|
1203
1207
|
code: "invalid_key",
|
|
1208
|
+
origin: "record",
|
|
1204
1209
|
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1205
1210
|
input: key,
|
|
1206
1211
|
path: [key],
|
|
@@ -1271,8 +1276,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
1271
1276
|
}
|
|
1272
1277
|
else {
|
|
1273
1278
|
final.issues.push({
|
|
1274
|
-
origin: "map",
|
|
1275
1279
|
code: "invalid_key",
|
|
1280
|
+
origin: "map",
|
|
1276
1281
|
input,
|
|
1277
1282
|
inst,
|
|
1278
1283
|
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
package/v4/core/schemas.d.cts
CHANGED
|
@@ -634,11 +634,13 @@ export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right ext
|
|
|
634
634
|
left: Left;
|
|
635
635
|
right: Right;
|
|
636
636
|
}
|
|
637
|
-
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
637
|
+
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
|
638
638
|
def: $ZodIntersectionDef<A, B>;
|
|
639
639
|
isst: never;
|
|
640
640
|
optin: A["_zod"]["optin"] | B["_zod"]["optin"];
|
|
641
641
|
optout: A["_zod"]["optout"] | B["_zod"]["optout"];
|
|
642
|
+
output: core.output<A> & core.output<B>;
|
|
643
|
+
input: core.input<A> & core.input<B>;
|
|
642
644
|
}
|
|
643
645
|
export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
|
644
646
|
_zod: $ZodIntersectionInternals<A, B>;
|
package/v4/core/schemas.d.ts
CHANGED
|
@@ -634,11 +634,13 @@ export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right ext
|
|
|
634
634
|
left: Left;
|
|
635
635
|
right: Right;
|
|
636
636
|
}
|
|
637
|
-
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
637
|
+
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
|
638
638
|
def: $ZodIntersectionDef<A, B>;
|
|
639
639
|
isst: never;
|
|
640
640
|
optin: A["_zod"]["optin"] | B["_zod"]["optin"];
|
|
641
641
|
optout: A["_zod"]["optout"] | B["_zod"]["optout"];
|
|
642
|
+
output: core.output<A> & core.output<B>;
|
|
643
|
+
input: core.input<A> & core.input<B>;
|
|
642
644
|
}
|
|
643
645
|
export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
|
644
646
|
_zod: $ZodIntersectionInternals<A, B>;
|