zod 3.25.69 → 3.25.70
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/v4/classic/compat.cjs +1 -7
- package/v4/classic/compat.d.cts +0 -2
- package/v4/classic/compat.d.ts +0 -2
- package/v4/classic/compat.js +0 -6
- package/v4/classic/external.cjs +2 -1
- package/v4/classic/external.d.cts +1 -1
- package/v4/classic/external.d.ts +1 -1
- package/v4/classic/external.js +1 -1
- package/v4/classic/schemas.d.cts +4 -4
- package/v4/classic/schemas.d.ts +4 -4
- package/v4/core/api.cjs +11 -10
- package/v4/core/api.js +11 -10
- package/v4/core/checks.cjs +6 -4
- package/v4/core/checks.js +6 -4
- package/v4/core/core.cjs +5 -1
- package/v4/core/core.d.cts +2 -0
- package/v4/core/core.d.ts +2 -0
- package/v4/core/core.js +4 -0
- package/v4/core/schemas.cjs +12 -13
- package/v4/core/schemas.js +12 -13
- package/v4/core/util.cjs +3 -0
- package/v4/core/util.d.cts +1 -1
- package/v4/core/util.d.ts +1 -1
- package/v4/core/util.js +3 -0
- package/v4/mini/external.cjs +2 -1
- package/v4/mini/external.d.cts +1 -1
- package/v4/mini/external.d.ts +1 -1
- package/v4/mini/external.js +1 -1
package/package.json
CHANGED
package/v4/classic/compat.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.config = exports.$brand = exports.
|
|
27
|
+
exports.config = exports.$brand = exports.ZodIssueCode = void 0;
|
|
28
28
|
exports.setErrorMap = setErrorMap;
|
|
29
29
|
exports.getErrorMap = getErrorMap;
|
|
30
30
|
const core = __importStar(require("../core/index.cjs"));
|
|
@@ -42,12 +42,6 @@ exports.ZodIssueCode = {
|
|
|
42
42
|
invalid_value: "invalid_value",
|
|
43
43
|
custom: "custom",
|
|
44
44
|
};
|
|
45
|
-
/** @deprecated Not necessary in Zod 4. */
|
|
46
|
-
const INVALID = Object.freeze({
|
|
47
|
-
status: "aborted",
|
|
48
|
-
});
|
|
49
|
-
/** A special constant with type `never` */
|
|
50
|
-
exports.NEVER = INVALID;
|
|
51
45
|
var index_js_1 = require("../core/index.cjs");
|
|
52
46
|
Object.defineProperty(exports, "$brand", { enumerable: true, get: function () { return index_js_1.$brand; } });
|
|
53
47
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return index_js_1.config; } });
|
package/v4/classic/compat.d.cts
CHANGED
|
@@ -21,8 +21,6 @@ export declare const ZodIssueCode: {
|
|
|
21
21
|
readonly invalid_value: "invalid_value";
|
|
22
22
|
readonly custom: "custom";
|
|
23
23
|
};
|
|
24
|
-
/** A special constant with type `never` */
|
|
25
|
-
export declare const NEVER: never;
|
|
26
24
|
/** @deprecated Use `z.$ZodFlattenedError` */
|
|
27
25
|
export type inferFlattenedErrors<T extends core.$ZodType, U = string> = core.$ZodFlattenedError<core.output<T>, U>;
|
|
28
26
|
/** @deprecated Use `z.$ZodFormattedError` */
|
package/v4/classic/compat.d.ts
CHANGED
|
@@ -21,8 +21,6 @@ export declare const ZodIssueCode: {
|
|
|
21
21
|
readonly invalid_value: "invalid_value";
|
|
22
22
|
readonly custom: "custom";
|
|
23
23
|
};
|
|
24
|
-
/** A special constant with type `never` */
|
|
25
|
-
export declare const NEVER: never;
|
|
26
24
|
/** @deprecated Use `z.$ZodFlattenedError` */
|
|
27
25
|
export type inferFlattenedErrors<T extends core.$ZodType, U = string> = core.$ZodFlattenedError<core.output<T>, U>;
|
|
28
26
|
/** @deprecated Use `z.$ZodFormattedError` */
|
package/v4/classic/compat.js
CHANGED
|
@@ -14,12 +14,6 @@ export const ZodIssueCode = {
|
|
|
14
14
|
invalid_value: "invalid_value",
|
|
15
15
|
custom: "custom",
|
|
16
16
|
};
|
|
17
|
-
/** @deprecated Not necessary in Zod 4. */
|
|
18
|
-
const INVALID = Object.freeze({
|
|
19
|
-
status: "aborted",
|
|
20
|
-
});
|
|
21
|
-
/** A special constant with type `never` */
|
|
22
|
-
export const NEVER = INVALID;
|
|
23
17
|
export { $brand, config } from "../core/index.js";
|
|
24
18
|
/** @deprecated Use `z.config(params)` instead. */
|
|
25
19
|
export function setErrorMap(map) {
|
package/v4/classic/external.cjs
CHANGED
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.function = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
|
32
|
+
exports.coerce = exports.iso = exports.ZodISODuration = exports.ZodISOTime = exports.ZodISODate = exports.ZodISODateTime = exports.locales = exports.NEVER = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.$brand = exports.$input = exports.$output = exports.function = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
|
33
33
|
exports.core = __importStar(require("../core/index.cjs"));
|
|
34
34
|
__exportStar(require("./schemas.cjs"), exports);
|
|
35
35
|
__exportStar(require("./checks.cjs"), exports);
|
|
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "formatError", { enumerable: true, get: function
|
|
|
56
56
|
Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return index_js_2.flattenError; } });
|
|
57
57
|
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return index_js_2.toJSONSchema; } });
|
|
58
58
|
Object.defineProperty(exports, "TimePrecision", { enumerable: true, get: function () { return index_js_2.TimePrecision; } });
|
|
59
|
+
Object.defineProperty(exports, "NEVER", { enumerable: true, get: function () { return index_js_2.NEVER; } });
|
|
59
60
|
exports.locales = __importStar(require("../locales/index.cjs"));
|
|
60
61
|
// iso
|
|
61
62
|
// must be exported from top-level
|
|
@@ -5,7 +5,7 @@ export * from "./errors.cjs";
|
|
|
5
5
|
export * from "./parse.cjs";
|
|
6
6
|
export * from "./compat.cjs";
|
|
7
7
|
export type { infer, output, input } from "../core/index.cjs";
|
|
8
|
-
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.cjs";
|
|
8
|
+
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.cjs";
|
|
9
9
|
export * as locales from "../locales/index.cjs";
|
|
10
10
|
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.cjs";
|
|
11
11
|
export * as iso from "./iso.cjs";
|
package/v4/classic/external.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./errors.js";
|
|
|
5
5
|
export * from "./parse.js";
|
|
6
6
|
export * from "./compat.js";
|
|
7
7
|
export type { infer, output, input } from "../core/index.js";
|
|
8
|
-
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.js";
|
|
8
|
+
export { globalRegistry, type GlobalMeta, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
|
|
9
9
|
export * as locales from "../locales/index.js";
|
|
10
10
|
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
|
|
11
11
|
export * as iso from "./iso.js";
|
package/v4/classic/external.js
CHANGED
|
@@ -8,7 +8,7 @@ export * from "./compat.js";
|
|
|
8
8
|
import { config } from "../core/index.js";
|
|
9
9
|
import en from "../locales/en.js";
|
|
10
10
|
config(en());
|
|
11
|
-
export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.js";
|
|
11
|
+
export { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
|
|
12
12
|
export * as locales from "../locales/index.js";
|
|
13
13
|
// iso
|
|
14
14
|
// must be exported from top-level
|
package/v4/classic/schemas.d.cts
CHANGED
|
@@ -428,18 +428,18 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
|
|
428
428
|
* ```
|
|
429
429
|
*/
|
|
430
430
|
merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
|
|
431
|
-
pick<M extends util.
|
|
432
|
-
omit<M extends util.
|
|
431
|
+
pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
|
432
|
+
omit<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
|
433
433
|
partial(): ZodObject<{
|
|
434
434
|
[k in keyof Shape]: ZodOptional<Shape[k]>;
|
|
435
435
|
}, Config>;
|
|
436
|
-
partial<M extends util.
|
|
436
|
+
partial<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
|
|
437
437
|
[k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
|
|
438
438
|
}, Config>;
|
|
439
439
|
required(): ZodObject<{
|
|
440
440
|
[k in keyof Shape]: ZodNonOptional<Shape[k]>;
|
|
441
441
|
}, Config>;
|
|
442
|
-
required<M extends util.
|
|
442
|
+
required<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
|
|
443
443
|
[k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
|
|
444
444
|
}, Config>;
|
|
445
445
|
}
|
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -428,18 +428,18 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
|
|
428
428
|
* ```
|
|
429
429
|
*/
|
|
430
430
|
merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
|
|
431
|
-
pick<M extends util.
|
|
432
|
-
omit<M extends util.
|
|
431
|
+
pick<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
|
432
|
+
omit<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
|
433
433
|
partial(): ZodObject<{
|
|
434
434
|
[k in keyof Shape]: ZodOptional<Shape[k]>;
|
|
435
435
|
}, Config>;
|
|
436
|
-
partial<M extends util.
|
|
436
|
+
partial<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
|
|
437
437
|
[k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k];
|
|
438
438
|
}, Config>;
|
|
439
439
|
required(): ZodObject<{
|
|
440
440
|
[k in keyof Shape]: ZodNonOptional<Shape[k]>;
|
|
441
441
|
}, Config>;
|
|
442
|
-
required<M extends util.
|
|
442
|
+
required<M extends util.Mask<keyof Shape>>(mask: M): ZodObject<{
|
|
443
443
|
[k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
|
|
444
444
|
}, Config>;
|
|
445
445
|
}
|
package/v4/core/api.cjs
CHANGED
|
@@ -965,10 +965,10 @@ function _refine(Class, fn, _params) {
|
|
|
965
965
|
return schema;
|
|
966
966
|
}
|
|
967
967
|
function _stringbool(Classes, _params) {
|
|
968
|
-
const
|
|
969
|
-
let truthyArray = truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
970
|
-
let falsyArray = falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
971
|
-
if (
|
|
968
|
+
const params = util.normalizeParams(_params);
|
|
969
|
+
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
970
|
+
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
971
|
+
if (params.case !== "sensitive") {
|
|
972
972
|
truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
|
|
973
973
|
falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
|
|
974
974
|
}
|
|
@@ -982,7 +982,7 @@ function _stringbool(Classes, _params) {
|
|
|
982
982
|
type: "transform",
|
|
983
983
|
transform: (input, payload) => {
|
|
984
984
|
let data = input;
|
|
985
|
-
if (
|
|
985
|
+
if (params.case !== "sensitive")
|
|
986
986
|
data = data.toLowerCase();
|
|
987
987
|
if (truthySet.has(data)) {
|
|
988
988
|
return true;
|
|
@@ -1001,22 +1001,23 @@ function _stringbool(Classes, _params) {
|
|
|
1001
1001
|
return {};
|
|
1002
1002
|
}
|
|
1003
1003
|
},
|
|
1004
|
-
error,
|
|
1004
|
+
error: params.error,
|
|
1005
1005
|
});
|
|
1006
|
+
// params.error;
|
|
1006
1007
|
const innerPipe = new _Pipe({
|
|
1007
1008
|
type: "pipe",
|
|
1008
|
-
in: new _String({ type: "string", error }),
|
|
1009
|
+
in: new _String({ type: "string", error: params.error }),
|
|
1009
1010
|
out: tx,
|
|
1010
|
-
error,
|
|
1011
|
+
error: params.error,
|
|
1011
1012
|
});
|
|
1012
1013
|
const outerPipe = new _Pipe({
|
|
1013
1014
|
type: "pipe",
|
|
1014
1015
|
in: innerPipe,
|
|
1015
1016
|
out: new _Boolean({
|
|
1016
1017
|
type: "boolean",
|
|
1017
|
-
error,
|
|
1018
|
+
error: params.error,
|
|
1018
1019
|
}),
|
|
1019
|
-
error,
|
|
1020
|
+
error: params.error,
|
|
1020
1021
|
});
|
|
1021
1022
|
return outerPipe;
|
|
1022
1023
|
}
|
package/v4/core/api.js
CHANGED
|
@@ -832,10 +832,10 @@ export function _refine(Class, fn, _params) {
|
|
|
832
832
|
return schema;
|
|
833
833
|
}
|
|
834
834
|
export function _stringbool(Classes, _params) {
|
|
835
|
-
const
|
|
836
|
-
let truthyArray = truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
837
|
-
let falsyArray = falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
838
|
-
if (
|
|
835
|
+
const params = util.normalizeParams(_params);
|
|
836
|
+
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
837
|
+
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
838
|
+
if (params.case !== "sensitive") {
|
|
839
839
|
truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
|
|
840
840
|
falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
|
|
841
841
|
}
|
|
@@ -849,7 +849,7 @@ export function _stringbool(Classes, _params) {
|
|
|
849
849
|
type: "transform",
|
|
850
850
|
transform: (input, payload) => {
|
|
851
851
|
let data = input;
|
|
852
|
-
if (
|
|
852
|
+
if (params.case !== "sensitive")
|
|
853
853
|
data = data.toLowerCase();
|
|
854
854
|
if (truthySet.has(data)) {
|
|
855
855
|
return true;
|
|
@@ -868,22 +868,23 @@ export function _stringbool(Classes, _params) {
|
|
|
868
868
|
return {};
|
|
869
869
|
}
|
|
870
870
|
},
|
|
871
|
-
error,
|
|
871
|
+
error: params.error,
|
|
872
872
|
});
|
|
873
|
+
// params.error;
|
|
873
874
|
const innerPipe = new _Pipe({
|
|
874
875
|
type: "pipe",
|
|
875
|
-
in: new _String({ type: "string", error }),
|
|
876
|
+
in: new _String({ type: "string", error: params.error }),
|
|
876
877
|
out: tx,
|
|
877
|
-
error,
|
|
878
|
+
error: params.error,
|
|
878
879
|
});
|
|
879
880
|
const outerPipe = new _Pipe({
|
|
880
881
|
type: "pipe",
|
|
881
882
|
in: innerPipe,
|
|
882
883
|
out: new _Boolean({
|
|
883
884
|
type: "boolean",
|
|
884
|
-
error,
|
|
885
|
+
error: params.error,
|
|
885
886
|
}),
|
|
886
|
-
error,
|
|
887
|
+
error: params.error,
|
|
887
888
|
});
|
|
888
889
|
return outerPipe;
|
|
889
890
|
}
|
package/v4/core/checks.cjs
CHANGED
|
@@ -85,7 +85,7 @@ exports.$ZodCheckGreaterThan = core.$constructor("$ZodCheckGreaterThan", (inst,
|
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
payload.issues.push({
|
|
88
|
-
origin
|
|
88
|
+
origin,
|
|
89
89
|
code: "too_small",
|
|
90
90
|
minimum: def.value,
|
|
91
91
|
input: payload.value,
|
|
@@ -320,6 +320,8 @@ exports.$ZodCheckSizeEquals = core.$constructor("$ZodCheckSizeEquals", (inst, de
|
|
|
320
320
|
payload.issues.push({
|
|
321
321
|
origin: util.getSizableOrigin(input),
|
|
322
322
|
...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
|
|
323
|
+
inclusive: true,
|
|
324
|
+
exact: true,
|
|
323
325
|
input: payload.value,
|
|
324
326
|
inst,
|
|
325
327
|
continue: !def.abort,
|
|
@@ -403,9 +405,9 @@ exports.$ZodCheckLengthEquals = core.$constructor("$ZodCheckLengthEquals", (inst
|
|
|
403
405
|
const tooBig = length > def.length;
|
|
404
406
|
payload.issues.push({
|
|
405
407
|
origin,
|
|
406
|
-
...(tooBig
|
|
407
|
-
|
|
408
|
-
|
|
408
|
+
...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
|
|
409
|
+
inclusive: true,
|
|
410
|
+
exact: true,
|
|
409
411
|
input: payload.value,
|
|
410
412
|
inst,
|
|
411
413
|
continue: !def.abort,
|
package/v4/core/checks.js
CHANGED
|
@@ -59,7 +59,7 @@ export const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor("$ZodCheckGr
|
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
payload.issues.push({
|
|
62
|
-
origin
|
|
62
|
+
origin,
|
|
63
63
|
code: "too_small",
|
|
64
64
|
minimum: def.value,
|
|
65
65
|
input: payload.value,
|
|
@@ -294,6 +294,8 @@ export const $ZodCheckSizeEquals = /*@__PURE__*/ core.$constructor("$ZodCheckSiz
|
|
|
294
294
|
payload.issues.push({
|
|
295
295
|
origin: util.getSizableOrigin(input),
|
|
296
296
|
...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
|
|
297
|
+
inclusive: true,
|
|
298
|
+
exact: true,
|
|
297
299
|
input: payload.value,
|
|
298
300
|
inst,
|
|
299
301
|
continue: !def.abort,
|
|
@@ -377,9 +379,9 @@ export const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor("$ZodCheckL
|
|
|
377
379
|
const tooBig = length > def.length;
|
|
378
380
|
payload.issues.push({
|
|
379
381
|
origin,
|
|
380
|
-
...(tooBig
|
|
381
|
-
|
|
382
|
-
|
|
382
|
+
...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
|
|
383
|
+
inclusive: true,
|
|
384
|
+
exact: true,
|
|
383
385
|
input: payload.value,
|
|
384
386
|
inst,
|
|
385
387
|
continue: !def.abort,
|
package/v4/core/core.cjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.globalConfig = exports.$ZodAsyncError = exports.$brand = void 0;
|
|
3
|
+
exports.globalConfig = exports.$ZodAsyncError = exports.$brand = exports.NEVER = void 0;
|
|
4
4
|
exports.$constructor = $constructor;
|
|
5
5
|
exports.config = config;
|
|
6
|
+
/** A special constant with type `never` */
|
|
7
|
+
exports.NEVER = Object.freeze({
|
|
8
|
+
status: "aborted",
|
|
9
|
+
});
|
|
6
10
|
function $constructor(name, initializer, params) {
|
|
7
11
|
function init(inst, def) {
|
|
8
12
|
var _a;
|
package/v4/core/core.d.cts
CHANGED
|
@@ -11,6 +11,8 @@ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
|
|
|
11
11
|
new (def: D): T;
|
|
12
12
|
init(inst: T, def: D): asserts inst is T;
|
|
13
13
|
}
|
|
14
|
+
/** A special constant with type `never` */
|
|
15
|
+
export declare const NEVER: never;
|
|
14
16
|
export declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void, params?: {
|
|
15
17
|
Parent?: typeof Class;
|
|
16
18
|
}): $constructor<T, D>;
|
package/v4/core/core.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
|
|
|
11
11
|
new (def: D): T;
|
|
12
12
|
init(inst: T, def: D): asserts inst is T;
|
|
13
13
|
}
|
|
14
|
+
/** A special constant with type `never` */
|
|
15
|
+
export declare const NEVER: never;
|
|
14
16
|
export declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void, params?: {
|
|
15
17
|
Parent?: typeof Class;
|
|
16
18
|
}): $constructor<T, D>;
|
package/v4/core/core.js
CHANGED
package/v4/core/schemas.cjs
CHANGED
|
@@ -512,13 +512,12 @@ exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
|
|
|
512
512
|
payload.value = BigInt(payload.value);
|
|
513
513
|
}
|
|
514
514
|
catch (_) { }
|
|
515
|
-
|
|
516
|
-
if (typeof input === "bigint")
|
|
515
|
+
if (typeof payload.value === "bigint")
|
|
517
516
|
return payload;
|
|
518
517
|
payload.issues.push({
|
|
519
518
|
expected: "bigint",
|
|
520
519
|
code: "invalid_type",
|
|
521
|
-
input,
|
|
520
|
+
input: payload.value,
|
|
522
521
|
inst,
|
|
523
522
|
});
|
|
524
523
|
return payload;
|
|
@@ -531,7 +530,7 @@ exports.$ZodBigIntFormat = core.$constructor("$ZodBigInt", (inst, def) => {
|
|
|
531
530
|
exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => {
|
|
532
531
|
exports.$ZodType.init(inst, def);
|
|
533
532
|
inst._zod.parse = (payload, _ctx) => {
|
|
534
|
-
const
|
|
533
|
+
const input = payload.value;
|
|
535
534
|
if (typeof input === "symbol")
|
|
536
535
|
return payload;
|
|
537
536
|
payload.issues.push({
|
|
@@ -548,7 +547,7 @@ exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
|
|
|
548
547
|
inst._zod.pattern = regexes.undefined;
|
|
549
548
|
inst._zod.values = new Set([undefined]);
|
|
550
549
|
inst._zod.parse = (payload, _ctx) => {
|
|
551
|
-
const
|
|
550
|
+
const input = payload.value;
|
|
552
551
|
if (typeof input === "undefined")
|
|
553
552
|
return payload;
|
|
554
553
|
payload.issues.push({
|
|
@@ -565,7 +564,7 @@ exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => {
|
|
|
565
564
|
inst._zod.pattern = regexes.null;
|
|
566
565
|
inst._zod.values = new Set([null]);
|
|
567
566
|
inst._zod.parse = (payload, _ctx) => {
|
|
568
|
-
const
|
|
567
|
+
const input = payload.value;
|
|
569
568
|
if (input === null)
|
|
570
569
|
return payload;
|
|
571
570
|
payload.issues.push({
|
|
@@ -600,7 +599,7 @@ exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => {
|
|
|
600
599
|
exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => {
|
|
601
600
|
exports.$ZodType.init(inst, def);
|
|
602
601
|
inst._zod.parse = (payload, _ctx) => {
|
|
603
|
-
const
|
|
602
|
+
const input = payload.value;
|
|
604
603
|
if (typeof input === "undefined")
|
|
605
604
|
return payload;
|
|
606
605
|
payload.issues.push({
|
|
@@ -743,20 +742,20 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
743
742
|
});
|
|
744
743
|
const generateFastpass = (shape) => {
|
|
745
744
|
const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
|
|
746
|
-
const
|
|
745
|
+
const normalized = _normalized.value;
|
|
747
746
|
const parseStr = (key) => {
|
|
748
747
|
const k = util.esc(key);
|
|
749
748
|
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
750
749
|
};
|
|
751
750
|
doc.write(`const input = payload.value;`);
|
|
752
751
|
const ids = Object.create(null);
|
|
753
|
-
for (const key of keys) {
|
|
752
|
+
for (const key of normalized.keys) {
|
|
754
753
|
ids[key] = util.randomString(15);
|
|
755
754
|
}
|
|
756
755
|
// A: preserve key order {
|
|
757
756
|
doc.write(`const newResult = {}`);
|
|
758
|
-
for (const key of keys) {
|
|
759
|
-
if (optionalKeys.has(key)) {
|
|
757
|
+
for (const key of normalized.keys) {
|
|
758
|
+
if (normalized.optionalKeys.has(key)) {
|
|
760
759
|
const id = ids[key];
|
|
761
760
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
762
761
|
const k = util.esc(key);
|
|
@@ -803,7 +802,7 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
803
802
|
const jit = !core.globalConfig.jitless;
|
|
804
803
|
const allowsEval = util.allowsEval;
|
|
805
804
|
const fastEnabled = jit && allowsEval.value; // && !def.catchall;
|
|
806
|
-
const
|
|
805
|
+
const catchall = def.catchall;
|
|
807
806
|
let value;
|
|
808
807
|
inst._zod.parse = (payload, ctx) => {
|
|
809
808
|
value ?? (value = _normalized.value);
|
|
@@ -1018,7 +1017,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1018
1017
|
exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => {
|
|
1019
1018
|
exports.$ZodType.init(inst, def);
|
|
1020
1019
|
inst._zod.parse = (payload, ctx) => {
|
|
1021
|
-
const
|
|
1020
|
+
const input = payload.value;
|
|
1022
1021
|
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
1023
1022
|
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
1024
1023
|
const async = left instanceof Promise || right instanceof Promise;
|
package/v4/core/schemas.js
CHANGED
|
@@ -481,13 +481,12 @@ export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, d
|
|
|
481
481
|
payload.value = BigInt(payload.value);
|
|
482
482
|
}
|
|
483
483
|
catch (_) { }
|
|
484
|
-
|
|
485
|
-
if (typeof input === "bigint")
|
|
484
|
+
if (typeof payload.value === "bigint")
|
|
486
485
|
return payload;
|
|
487
486
|
payload.issues.push({
|
|
488
487
|
expected: "bigint",
|
|
489
488
|
code: "invalid_type",
|
|
490
|
-
input,
|
|
489
|
+
input: payload.value,
|
|
491
490
|
inst,
|
|
492
491
|
});
|
|
493
492
|
return payload;
|
|
@@ -500,7 +499,7 @@ export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigInt", (i
|
|
|
500
499
|
export const $ZodSymbol = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
|
|
501
500
|
$ZodType.init(inst, def);
|
|
502
501
|
inst._zod.parse = (payload, _ctx) => {
|
|
503
|
-
const
|
|
502
|
+
const input = payload.value;
|
|
504
503
|
if (typeof input === "symbol")
|
|
505
504
|
return payload;
|
|
506
505
|
payload.issues.push({
|
|
@@ -517,7 +516,7 @@ export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (i
|
|
|
517
516
|
inst._zod.pattern = regexes.undefined;
|
|
518
517
|
inst._zod.values = new Set([undefined]);
|
|
519
518
|
inst._zod.parse = (payload, _ctx) => {
|
|
520
|
-
const
|
|
519
|
+
const input = payload.value;
|
|
521
520
|
if (typeof input === "undefined")
|
|
522
521
|
return payload;
|
|
523
522
|
payload.issues.push({
|
|
@@ -534,7 +533,7 @@ export const $ZodNull = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def)
|
|
|
534
533
|
inst._zod.pattern = regexes.null;
|
|
535
534
|
inst._zod.values = new Set([null]);
|
|
536
535
|
inst._zod.parse = (payload, _ctx) => {
|
|
537
|
-
const
|
|
536
|
+
const input = payload.value;
|
|
538
537
|
if (input === null)
|
|
539
538
|
return payload;
|
|
540
539
|
payload.issues.push({
|
|
@@ -569,7 +568,7 @@ export const $ZodNever = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def
|
|
|
569
568
|
export const $ZodVoid = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
|
|
570
569
|
$ZodType.init(inst, def);
|
|
571
570
|
inst._zod.parse = (payload, _ctx) => {
|
|
572
|
-
const
|
|
571
|
+
const input = payload.value;
|
|
573
572
|
if (typeof input === "undefined")
|
|
574
573
|
return payload;
|
|
575
574
|
payload.issues.push({
|
|
@@ -712,20 +711,20 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
712
711
|
});
|
|
713
712
|
const generateFastpass = (shape) => {
|
|
714
713
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
715
|
-
const
|
|
714
|
+
const normalized = _normalized.value;
|
|
716
715
|
const parseStr = (key) => {
|
|
717
716
|
const k = util.esc(key);
|
|
718
717
|
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
719
718
|
};
|
|
720
719
|
doc.write(`const input = payload.value;`);
|
|
721
720
|
const ids = Object.create(null);
|
|
722
|
-
for (const key of keys) {
|
|
721
|
+
for (const key of normalized.keys) {
|
|
723
722
|
ids[key] = util.randomString(15);
|
|
724
723
|
}
|
|
725
724
|
// A: preserve key order {
|
|
726
725
|
doc.write(`const newResult = {}`);
|
|
727
|
-
for (const key of keys) {
|
|
728
|
-
if (optionalKeys.has(key)) {
|
|
726
|
+
for (const key of normalized.keys) {
|
|
727
|
+
if (normalized.optionalKeys.has(key)) {
|
|
729
728
|
const id = ids[key];
|
|
730
729
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
731
730
|
const k = util.esc(key);
|
|
@@ -772,7 +771,7 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
772
771
|
const jit = !core.globalConfig.jitless;
|
|
773
772
|
const allowsEval = util.allowsEval;
|
|
774
773
|
const fastEnabled = jit && allowsEval.value; // && !def.catchall;
|
|
775
|
-
const
|
|
774
|
+
const catchall = def.catchall;
|
|
776
775
|
let value;
|
|
777
776
|
inst._zod.parse = (payload, ctx) => {
|
|
778
777
|
value ?? (value = _normalized.value);
|
|
@@ -987,7 +986,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
987
986
|
export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersection", (inst, def) => {
|
|
988
987
|
$ZodType.init(inst, def);
|
|
989
988
|
inst._zod.parse = (payload, ctx) => {
|
|
990
|
-
const
|
|
989
|
+
const input = payload.value;
|
|
991
990
|
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
992
991
|
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
993
992
|
const async = left instanceof Promise || right instanceof Promise;
|
package/v4/core/util.cjs
CHANGED
|
@@ -364,6 +364,9 @@ function omit(schema, mask) {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
function extend(schema, shape) {
|
|
367
|
+
if (!isPlainObject(shape)) {
|
|
368
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
369
|
+
}
|
|
367
370
|
const def = {
|
|
368
371
|
...schema._zod.def,
|
|
369
372
|
get shape() {
|
package/v4/core/util.d.cts
CHANGED
|
@@ -127,7 +127,7 @@ export declare function promiseAllObject<T extends object>(promisesObj: T): Prom
|
|
|
127
127
|
}>;
|
|
128
128
|
export declare function randomString(length?: number): string;
|
|
129
129
|
export declare function esc(str: string): string;
|
|
130
|
-
export declare const captureStackTrace:
|
|
130
|
+
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
|
131
131
|
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
|
132
132
|
export declare const allowsEval: {
|
|
133
133
|
value: boolean;
|
package/v4/core/util.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ export declare function promiseAllObject<T extends object>(promisesObj: T): Prom
|
|
|
127
127
|
}>;
|
|
128
128
|
export declare function randomString(length?: number): string;
|
|
129
129
|
export declare function esc(str: string): string;
|
|
130
|
-
export declare const captureStackTrace:
|
|
130
|
+
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
|
131
131
|
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
|
132
132
|
export declare const allowsEval: {
|
|
133
133
|
value: boolean;
|
package/v4/core/util.js
CHANGED
|
@@ -319,6 +319,9 @@ export function omit(schema, mask) {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
export function extend(schema, shape) {
|
|
322
|
+
if (!isPlainObject(shape)) {
|
|
323
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
324
|
+
}
|
|
322
325
|
const def = {
|
|
323
326
|
...schema._zod.def,
|
|
324
327
|
get shape() {
|
package/v4/mini/external.cjs
CHANGED
|
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.coerce = exports.ZodMiniISODuration = exports.ZodMiniISOTime = exports.ZodMiniISODate = exports.ZodMiniISODateTime = exports.iso = exports.locales = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.function = exports.$brand = exports.$input = exports.$output = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
|
29
|
+
exports.coerce = exports.ZodMiniISODuration = exports.ZodMiniISOTime = exports.ZodMiniISODate = exports.ZodMiniISODateTime = exports.iso = exports.locales = exports.NEVER = exports.TimePrecision = exports.toJSONSchema = exports.flattenError = exports.formatError = exports.prettifyError = exports.treeifyError = exports.regexes = exports.clone = exports.function = exports.$brand = exports.$input = exports.$output = exports.config = exports.registry = exports.globalRegistry = exports.core = void 0;
|
|
30
30
|
exports.core = __importStar(require("../core/index.cjs"));
|
|
31
31
|
__exportStar(require("./parse.cjs"), exports);
|
|
32
32
|
__exportStar(require("./schemas.cjs"), exports);
|
|
@@ -47,6 +47,7 @@ Object.defineProperty(exports, "formatError", { enumerable: true, get: function
|
|
|
47
47
|
Object.defineProperty(exports, "flattenError", { enumerable: true, get: function () { return index_js_1.flattenError; } });
|
|
48
48
|
Object.defineProperty(exports, "toJSONSchema", { enumerable: true, get: function () { return index_js_1.toJSONSchema; } });
|
|
49
49
|
Object.defineProperty(exports, "TimePrecision", { enumerable: true, get: function () { return index_js_1.TimePrecision; } });
|
|
50
|
+
Object.defineProperty(exports, "NEVER", { enumerable: true, get: function () { return index_js_1.NEVER; } });
|
|
50
51
|
exports.locales = __importStar(require("../locales/index.cjs"));
|
|
51
52
|
/** A special constant with type `never` */
|
|
52
53
|
// export const NEVER = {} as never;
|
package/v4/mini/external.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ export * from "./parse.cjs";
|
|
|
3
3
|
export * from "./schemas.cjs";
|
|
4
4
|
export * from "./checks.cjs";
|
|
5
5
|
export type { infer, output, input } from "../core/index.cjs";
|
|
6
|
-
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.cjs";
|
|
6
|
+
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.cjs";
|
|
7
7
|
export * as locales from "../locales/index.cjs";
|
|
8
8
|
/** A special constant with type `never` */
|
|
9
9
|
export * as iso from "./iso.cjs";
|
package/v4/mini/external.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from "./parse.js";
|
|
|
3
3
|
export * from "./schemas.js";
|
|
4
4
|
export * from "./checks.js";
|
|
5
5
|
export type { infer, output, input } from "../core/index.js";
|
|
6
|
-
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.js";
|
|
6
|
+
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
|
|
7
7
|
export * as locales from "../locales/index.js";
|
|
8
8
|
/** A special constant with type `never` */
|
|
9
9
|
export * as iso from "./iso.js";
|
package/v4/mini/external.js
CHANGED
|
@@ -2,7 +2,7 @@ export * as core from "../core/index.js";
|
|
|
2
2
|
export * from "./parse.js";
|
|
3
3
|
export * from "./schemas.js";
|
|
4
4
|
export * from "./checks.js";
|
|
5
|
-
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, } from "../core/index.js";
|
|
5
|
+
export { globalRegistry, registry, config, $output, $input, $brand, function, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from "../core/index.js";
|
|
6
6
|
export * as locales from "../locales/index.js";
|
|
7
7
|
/** A special constant with type `never` */
|
|
8
8
|
// export const NEVER = {} as never;
|