zod 4.0.0-beta.20250410T221232 → 4.0.0-beta.20250410T230029
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/schemas.d.ts +1 -1
- package/dist/commonjs/schemas.js +70 -70
- package/dist/esm/schemas.d.ts +1 -1
- package/dist/esm/schemas.js +1 -1
- package/package.json +2 -2
- package/src/errors.ts +3 -3
- package/src/schemas.ts +1 -1
package/dist/commonjs/schemas.js
CHANGED
|
@@ -123,7 +123,7 @@ exports.instanceof = _instanceof;
|
|
|
123
123
|
exports.json = json;
|
|
124
124
|
exports.preprocess = preprocess;
|
|
125
125
|
const core = __importStar(require("@zod/core"));
|
|
126
|
-
const
|
|
126
|
+
const core_1 = require("@zod/core");
|
|
127
127
|
const checks = __importStar(require("./checks.js"));
|
|
128
128
|
const iso = __importStar(require("./iso.js"));
|
|
129
129
|
const parse = __importStar(require("./parse.js"));
|
|
@@ -595,14 +595,14 @@ exports.ZodObjectLike = core.$constructor("ZodObjectLike", (inst, def) => {
|
|
|
595
595
|
});
|
|
596
596
|
function keyof(schema) {
|
|
597
597
|
const shape = schema._zod.def.type === "interface"
|
|
598
|
-
? util.cleanInterfaceShape(schema._zod.def.shape).shape
|
|
598
|
+
? core_1.util.cleanInterfaceShape(schema._zod.def.shape).shape
|
|
599
599
|
: schema._zod.def.shape;
|
|
600
600
|
return literal(Object.keys(shape));
|
|
601
601
|
}
|
|
602
602
|
exports.ZodInterface = core.$constructor("ZodInterface", (inst, def) => {
|
|
603
603
|
core.$ZodInterface.init(inst, def);
|
|
604
604
|
exports.ZodType.init(inst, def);
|
|
605
|
-
util.defineLazy(inst._zod, "shape", () => def.shape);
|
|
605
|
+
core_1.util.defineLazy(inst._zod, "shape", () => def.shape);
|
|
606
606
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
607
607
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
608
608
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
@@ -610,54 +610,54 @@ exports.ZodInterface = core.$constructor("ZodInterface", (inst, def) => {
|
|
|
610
610
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
611
611
|
inst.extend = (incoming) => {
|
|
612
612
|
if (incoming instanceof core.$ZodInterface)
|
|
613
|
-
return util.extendObjectLike(inst, incoming);
|
|
614
|
-
return util.extendObjectLike(inst, _interface(incoming));
|
|
613
|
+
return core_1.util.extendObjectLike(inst, incoming);
|
|
614
|
+
return core_1.util.extendObjectLike(inst, _interface(incoming));
|
|
615
615
|
};
|
|
616
|
-
inst.merge = (other) => util.mergeObjectLike(inst, other);
|
|
617
|
-
inst.pick = (mask) => util.pick(inst, mask);
|
|
618
|
-
inst.omit = (mask) => util.omit(inst, mask);
|
|
619
|
-
inst.partial = (...args) => util.partialObjectLike(exports.ZodOptional, inst, args[0]);
|
|
620
|
-
inst.required = (...args) => util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
|
|
616
|
+
inst.merge = (other) => core_1.util.mergeObjectLike(inst, other);
|
|
617
|
+
inst.pick = (mask) => core_1.util.pick(inst, mask);
|
|
618
|
+
inst.omit = (mask) => core_1.util.omit(inst, mask);
|
|
619
|
+
inst.partial = (...args) => core_1.util.partialObjectLike(exports.ZodOptional, inst, args[0]);
|
|
620
|
+
inst.required = (...args) => core_1.util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
|
|
621
621
|
});
|
|
622
622
|
function _interface(shape, params, Class = exports.ZodInterface) {
|
|
623
|
-
const cleaned = util.cached(() => util.cleanInterfaceShape(shape));
|
|
623
|
+
const cleaned = core_1.util.cached(() => core_1.util.cleanInterfaceShape(shape));
|
|
624
624
|
const def = {
|
|
625
625
|
type: "interface",
|
|
626
626
|
get shape() {
|
|
627
627
|
// return cleaned.value.shape;
|
|
628
628
|
const _shape = cleaned.value.shape;
|
|
629
|
-
util.assignProp(this, "shape", _shape);
|
|
629
|
+
core_1.util.assignProp(this, "shape", _shape);
|
|
630
630
|
return _shape;
|
|
631
631
|
},
|
|
632
632
|
get optional() {
|
|
633
633
|
return cleaned.value.optional;
|
|
634
634
|
},
|
|
635
|
-
...util.normalizeParams(params),
|
|
635
|
+
...core_1.util.normalizeParams(params),
|
|
636
636
|
};
|
|
637
637
|
return new Class(def);
|
|
638
638
|
}
|
|
639
639
|
// strictInterface
|
|
640
640
|
function strictInterface(shape, params) {
|
|
641
|
-
const cleaned = util.cached(() => util.cleanInterfaceShape(shape));
|
|
641
|
+
const cleaned = core_1.util.cached(() => core_1.util.cleanInterfaceShape(shape));
|
|
642
642
|
const def = {
|
|
643
643
|
type: "interface",
|
|
644
644
|
get shape() {
|
|
645
645
|
// return cleaned.value.shape;
|
|
646
646
|
const _shape = cleaned.value.shape;
|
|
647
|
-
util.assignProp(this, "shape", _shape);
|
|
647
|
+
core_1.util.assignProp(this, "shape", _shape);
|
|
648
648
|
return _shape;
|
|
649
649
|
},
|
|
650
650
|
get optional() {
|
|
651
651
|
return cleaned.value.optional;
|
|
652
652
|
},
|
|
653
653
|
catchall: never(),
|
|
654
|
-
...util.normalizeParams(params),
|
|
654
|
+
...core_1.util.normalizeParams(params),
|
|
655
655
|
};
|
|
656
656
|
return new exports.ZodInterface(def);
|
|
657
657
|
}
|
|
658
658
|
// looseInterface
|
|
659
659
|
function looseInterface(shape, params) {
|
|
660
|
-
const cleaned = util.cached(() => util.cleanInterfaceShape(shape));
|
|
660
|
+
const cleaned = core_1.util.cached(() => core_1.util.cleanInterfaceShape(shape));
|
|
661
661
|
const def = {
|
|
662
662
|
type: "interface",
|
|
663
663
|
get optional() {
|
|
@@ -666,11 +666,11 @@ function looseInterface(shape, params) {
|
|
|
666
666
|
get shape() {
|
|
667
667
|
// return cleaned.value.shape;
|
|
668
668
|
const _shape = cleaned.value.shape;
|
|
669
|
-
util.assignProp(this, "shape", _shape);
|
|
669
|
+
core_1.util.assignProp(this, "shape", _shape);
|
|
670
670
|
return _shape;
|
|
671
671
|
},
|
|
672
672
|
catchall: unknown(),
|
|
673
|
-
...util.normalizeParams(params),
|
|
673
|
+
...core_1.util.normalizeParams(params),
|
|
674
674
|
};
|
|
675
675
|
return new exports.ZodInterface(def);
|
|
676
676
|
}
|
|
@@ -687,23 +687,23 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
|
687
687
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
688
688
|
inst.extend = (incoming) => {
|
|
689
689
|
if (incoming instanceof exports.ZodObject)
|
|
690
|
-
return util.extendObjectLike(inst, incoming);
|
|
691
|
-
return util.extendObjectLike(inst, object(incoming));
|
|
690
|
+
return core_1.util.extendObjectLike(inst, incoming);
|
|
691
|
+
return core_1.util.extendObjectLike(inst, object(incoming));
|
|
692
692
|
};
|
|
693
|
-
inst.merge = (other) => util.mergeObjectLike(inst, other);
|
|
694
|
-
inst.pick = (mask) => util.pick(inst, mask);
|
|
695
|
-
inst.omit = (mask) => util.omit(inst, mask);
|
|
696
|
-
inst.partial = (...args) => util.partialObjectLike(exports.ZodOptional, inst, args[0]);
|
|
697
|
-
inst.required = (...args) => util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
|
|
693
|
+
inst.merge = (other) => core_1.util.mergeObjectLike(inst, other);
|
|
694
|
+
inst.pick = (mask) => core_1.util.pick(inst, mask);
|
|
695
|
+
inst.omit = (mask) => core_1.util.omit(inst, mask);
|
|
696
|
+
inst.partial = (...args) => core_1.util.partialObjectLike(exports.ZodOptional, inst, args[0]);
|
|
697
|
+
inst.required = (...args) => core_1.util.requiredObjectLike(exports.ZodNonOptional, inst, args[0]);
|
|
698
698
|
});
|
|
699
699
|
function object(shape, params) {
|
|
700
700
|
const def = {
|
|
701
701
|
type: "object",
|
|
702
702
|
shape: shape ?? {},
|
|
703
703
|
get optional() {
|
|
704
|
-
return util.optionalObjectKeys(shape ?? {});
|
|
704
|
+
return core_1.util.optionalObjectKeys(shape ?? {});
|
|
705
705
|
},
|
|
706
|
-
...util.normalizeParams(params),
|
|
706
|
+
...core_1.util.normalizeParams(params),
|
|
707
707
|
};
|
|
708
708
|
return new exports.ZodObject(def);
|
|
709
709
|
}
|
|
@@ -713,10 +713,10 @@ function strictObject(shape, params) {
|
|
|
713
713
|
type: "object",
|
|
714
714
|
shape: shape,
|
|
715
715
|
get optional() {
|
|
716
|
-
return util.optionalObjectKeys(shape);
|
|
716
|
+
return core_1.util.optionalObjectKeys(shape);
|
|
717
717
|
},
|
|
718
718
|
catchall: never(),
|
|
719
|
-
...util.normalizeParams(params),
|
|
719
|
+
...core_1.util.normalizeParams(params),
|
|
720
720
|
});
|
|
721
721
|
}
|
|
722
722
|
// looseObject
|
|
@@ -725,37 +725,37 @@ function looseObject(shape, params) {
|
|
|
725
725
|
type: "object",
|
|
726
726
|
shape: shape,
|
|
727
727
|
get optional() {
|
|
728
|
-
return util.optionalObjectKeys(shape);
|
|
728
|
+
return core_1.util.optionalObjectKeys(shape);
|
|
729
729
|
},
|
|
730
730
|
catchall: unknown(),
|
|
731
|
-
...util.normalizeParams(params),
|
|
731
|
+
...core_1.util.normalizeParams(params),
|
|
732
732
|
});
|
|
733
733
|
}
|
|
734
734
|
function extend(schema, shape) {
|
|
735
735
|
if (shape instanceof core.$ZodType)
|
|
736
|
-
return util.mergeObjectLike(schema, shape);
|
|
736
|
+
return core_1.util.mergeObjectLike(schema, shape);
|
|
737
737
|
if (schema instanceof exports.ZodInterface) {
|
|
738
|
-
return util.mergeObjectLike(schema, _interface(shape));
|
|
738
|
+
return core_1.util.mergeObjectLike(schema, _interface(shape));
|
|
739
739
|
}
|
|
740
740
|
if (schema instanceof exports.ZodObject)
|
|
741
|
-
return util.mergeObjectLike(schema, object(shape));
|
|
742
|
-
return util.extend(schema, shape);
|
|
741
|
+
return core_1.util.mergeObjectLike(schema, object(shape));
|
|
742
|
+
return core_1.util.extend(schema, shape);
|
|
743
743
|
}
|
|
744
744
|
function merge(a, b) {
|
|
745
|
-
return util.mergeObjectLike(a, b);
|
|
745
|
+
return core_1.util.mergeObjectLike(a, b);
|
|
746
746
|
}
|
|
747
747
|
function pick(schema, mask) {
|
|
748
748
|
// const picked = util.pick(schema, mask);
|
|
749
|
-
return util.pick(schema, mask);
|
|
749
|
+
return core_1.util.pick(schema, mask);
|
|
750
750
|
}
|
|
751
751
|
function omit(schema, mask) {
|
|
752
|
-
return util.omit(schema, mask);
|
|
752
|
+
return core_1.util.omit(schema, mask);
|
|
753
753
|
}
|
|
754
754
|
function partial(schema, mask) {
|
|
755
|
-
return util.partialObjectLike(exports.ZodOptional, schema, mask);
|
|
755
|
+
return core_1.util.partialObjectLike(exports.ZodOptional, schema, mask);
|
|
756
756
|
}
|
|
757
757
|
function required(schema, mask) {
|
|
758
|
-
return util.requiredObjectLike(exports.ZodNonOptional, schema, mask);
|
|
758
|
+
return core_1.util.requiredObjectLike(exports.ZodNonOptional, schema, mask);
|
|
759
759
|
}
|
|
760
760
|
exports.ZodUnion = core.$constructor("ZodUnion", (inst, def) => {
|
|
761
761
|
core.$ZodUnion.init(inst, def);
|
|
@@ -766,7 +766,7 @@ function union(options, params) {
|
|
|
766
766
|
return new exports.ZodUnion({
|
|
767
767
|
type: "union",
|
|
768
768
|
options,
|
|
769
|
-
...util.normalizeParams(params),
|
|
769
|
+
...core_1.util.normalizeParams(params),
|
|
770
770
|
});
|
|
771
771
|
}
|
|
772
772
|
exports.ZodDiscriminatedUnion = core.$constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
@@ -780,7 +780,7 @@ function discriminatedUnion(...args) {
|
|
|
780
780
|
return new exports.ZodDiscriminatedUnion({
|
|
781
781
|
type: "union",
|
|
782
782
|
options,
|
|
783
|
-
...util.normalizeParams(params),
|
|
783
|
+
...core_1.util.normalizeParams(params),
|
|
784
784
|
});
|
|
785
785
|
}
|
|
786
786
|
exports.ZodIntersection = core.$constructor("ZodIntersection", (inst, def) => {
|
|
@@ -792,7 +792,7 @@ function intersection(left, right, params) {
|
|
|
792
792
|
type: "intersection",
|
|
793
793
|
left,
|
|
794
794
|
right,
|
|
795
|
-
...util.normalizeParams(params),
|
|
795
|
+
...core_1.util.normalizeParams(params),
|
|
796
796
|
});
|
|
797
797
|
}
|
|
798
798
|
exports.ZodTuple = core.$constructor("ZodTuple", (inst, def) => {
|
|
@@ -811,7 +811,7 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
811
811
|
type: "tuple",
|
|
812
812
|
items,
|
|
813
813
|
rest,
|
|
814
|
-
...util.normalizeParams(params),
|
|
814
|
+
...core_1.util.normalizeParams(params),
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
817
|
exports.ZodRecord = core.$constructor("ZodRecord", (inst, def) => {
|
|
@@ -825,7 +825,7 @@ function record(keyType, valueType, params) {
|
|
|
825
825
|
type: "record",
|
|
826
826
|
keyType,
|
|
827
827
|
valueType,
|
|
828
|
-
...util.normalizeParams(params),
|
|
828
|
+
...core_1.util.normalizeParams(params),
|
|
829
829
|
});
|
|
830
830
|
}
|
|
831
831
|
exports.ZodMap = core.$constructor("ZodMap", (inst, def) => {
|
|
@@ -839,7 +839,7 @@ function map(keyType, valueType, params) {
|
|
|
839
839
|
type: "map",
|
|
840
840
|
keyType,
|
|
841
841
|
valueType,
|
|
842
|
-
...util.normalizeParams(params),
|
|
842
|
+
...core_1.util.normalizeParams(params),
|
|
843
843
|
});
|
|
844
844
|
}
|
|
845
845
|
exports.ZodSet = core.$constructor("ZodSet", (inst, def) => {
|
|
@@ -854,7 +854,7 @@ function set(valueType, params) {
|
|
|
854
854
|
return new exports.ZodSet({
|
|
855
855
|
type: "set",
|
|
856
856
|
valueType,
|
|
857
|
-
...util.normalizeParams(params),
|
|
857
|
+
...core_1.util.normalizeParams(params),
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
860
|
exports.ZodEnum = core.$constructor("ZodEnum", (inst, def) => {
|
|
@@ -875,7 +875,7 @@ exports.ZodEnum = core.$constructor("ZodEnum", (inst, def) => {
|
|
|
875
875
|
return new exports.ZodEnum({
|
|
876
876
|
...def,
|
|
877
877
|
checks: [],
|
|
878
|
-
...util.normalizeParams(params),
|
|
878
|
+
...core_1.util.normalizeParams(params),
|
|
879
879
|
entries: newEntries,
|
|
880
880
|
});
|
|
881
881
|
};
|
|
@@ -891,7 +891,7 @@ exports.ZodEnum = core.$constructor("ZodEnum", (inst, def) => {
|
|
|
891
891
|
return new exports.ZodEnum({
|
|
892
892
|
...def,
|
|
893
893
|
checks: [],
|
|
894
|
-
...util.normalizeParams(params),
|
|
894
|
+
...core_1.util.normalizeParams(params),
|
|
895
895
|
entries: newEntries,
|
|
896
896
|
});
|
|
897
897
|
};
|
|
@@ -901,7 +901,7 @@ function _enum(values, params) {
|
|
|
901
901
|
return new exports.ZodEnum({
|
|
902
902
|
type: "enum",
|
|
903
903
|
entries,
|
|
904
|
-
...util.normalizeParams(params),
|
|
904
|
+
...core_1.util.normalizeParams(params),
|
|
905
905
|
});
|
|
906
906
|
}
|
|
907
907
|
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
|
|
@@ -915,7 +915,7 @@ function nativeEnum(entries, params) {
|
|
|
915
915
|
return new exports.ZodEnum({
|
|
916
916
|
type: "enum",
|
|
917
917
|
entries,
|
|
918
|
-
...util.normalizeParams(params),
|
|
918
|
+
...core_1.util.normalizeParams(params),
|
|
919
919
|
});
|
|
920
920
|
}
|
|
921
921
|
exports.ZodLiteral = core.$constructor("ZodLiteral", (inst, def) => {
|
|
@@ -927,7 +927,7 @@ function literal(value, params) {
|
|
|
927
927
|
return new exports.ZodLiteral({
|
|
928
928
|
type: "literal",
|
|
929
929
|
values: Array.isArray(value) ? value : [value],
|
|
930
|
-
...util.normalizeParams(params),
|
|
930
|
+
...core_1.util.normalizeParams(params),
|
|
931
931
|
});
|
|
932
932
|
}
|
|
933
933
|
exports.ZodFile = core.$constructor("ZodFile", (inst, def) => {
|
|
@@ -946,7 +946,7 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
|
|
946
946
|
inst._zod.parse = (payload, _ctx) => {
|
|
947
947
|
payload.addIssue = (issue) => {
|
|
948
948
|
if (typeof issue === "string") {
|
|
949
|
-
payload.issues.push(util.issue(issue, payload.value, def));
|
|
949
|
+
payload.issues.push(core_1.util.issue(issue, payload.value, def));
|
|
950
950
|
}
|
|
951
951
|
else {
|
|
952
952
|
// for Zod 3 backwards compatibility
|
|
@@ -957,7 +957,7 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
|
|
957
957
|
_issue.input ?? (_issue.input = payload.value);
|
|
958
958
|
_issue.inst ?? (_issue.inst = inst);
|
|
959
959
|
_issue.continue ?? (_issue.continue = !def.abort);
|
|
960
|
-
payload.issues.push(util.issue(_issue));
|
|
960
|
+
payload.issues.push(core_1.util.issue(_issue));
|
|
961
961
|
}
|
|
962
962
|
};
|
|
963
963
|
const output = def.transform(payload.value, payload);
|
|
@@ -975,7 +975,7 @@ function transform(fn, params) {
|
|
|
975
975
|
return new exports.ZodTransform({
|
|
976
976
|
type: "transform",
|
|
977
977
|
transform: fn,
|
|
978
|
-
...util.normalizeParams(params),
|
|
978
|
+
...core_1.util.normalizeParams(params),
|
|
979
979
|
});
|
|
980
980
|
}
|
|
981
981
|
exports.ZodOptional = core.$constructor("ZodOptional", (inst, def) => {
|
|
@@ -987,7 +987,7 @@ function optional(innerType, params) {
|
|
|
987
987
|
return new exports.ZodOptional({
|
|
988
988
|
type: "optional",
|
|
989
989
|
innerType,
|
|
990
|
-
...util.normalizeParams(params),
|
|
990
|
+
...core_1.util.normalizeParams(params),
|
|
991
991
|
});
|
|
992
992
|
}
|
|
993
993
|
exports.ZodNullable = core.$constructor("ZodNullable", (inst, def) => {
|
|
@@ -999,7 +999,7 @@ function nullable(innerType, params) {
|
|
|
999
999
|
return new exports.ZodNullable({
|
|
1000
1000
|
type: "nullable",
|
|
1001
1001
|
innerType,
|
|
1002
|
-
...util.normalizeParams(params),
|
|
1002
|
+
...core_1.util.normalizeParams(params),
|
|
1003
1003
|
});
|
|
1004
1004
|
}
|
|
1005
1005
|
// nullish
|
|
@@ -1017,7 +1017,7 @@ function _default(innerType, defaultValue, params) {
|
|
|
1017
1017
|
type: "default",
|
|
1018
1018
|
defaultValue: (typeof defaultValue === "function" ? defaultValue : () => defaultValue),
|
|
1019
1019
|
innerType,
|
|
1020
|
-
...util.normalizeParams(params),
|
|
1020
|
+
...core_1.util.normalizeParams(params),
|
|
1021
1021
|
});
|
|
1022
1022
|
}
|
|
1023
1023
|
exports.ZodNonOptional = core.$constructor("ZodNonOptional", (inst, def) => {
|
|
@@ -1029,7 +1029,7 @@ function nonoptional(innerType, params) {
|
|
|
1029
1029
|
return new exports.ZodNonOptional({
|
|
1030
1030
|
type: "nonoptional",
|
|
1031
1031
|
innerType,
|
|
1032
|
-
...util.normalizeParams(params),
|
|
1032
|
+
...core_1.util.normalizeParams(params),
|
|
1033
1033
|
});
|
|
1034
1034
|
}
|
|
1035
1035
|
exports.ZodSuccess = core.$constructor("ZodSuccess", (inst, def) => {
|
|
@@ -1041,7 +1041,7 @@ function success(innerType, params) {
|
|
|
1041
1041
|
return new exports.ZodSuccess({
|
|
1042
1042
|
type: "success",
|
|
1043
1043
|
innerType,
|
|
1044
|
-
...util.normalizeParams(params),
|
|
1044
|
+
...core_1.util.normalizeParams(params),
|
|
1045
1045
|
});
|
|
1046
1046
|
}
|
|
1047
1047
|
exports.ZodCatch = core.$constructor("ZodCatch", (inst, def) => {
|
|
@@ -1055,7 +1055,7 @@ function _catch(innerType, catchValue, params) {
|
|
|
1055
1055
|
type: "catch",
|
|
1056
1056
|
innerType,
|
|
1057
1057
|
catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
|
|
1058
|
-
...util.normalizeParams(params),
|
|
1058
|
+
...core_1.util.normalizeParams(params),
|
|
1059
1059
|
});
|
|
1060
1060
|
}
|
|
1061
1061
|
exports.ZodNaN = core.$constructor("ZodNaN", (inst, def) => {
|
|
@@ -1076,7 +1076,7 @@ function pipe(in_, out, params) {
|
|
|
1076
1076
|
type: "pipe",
|
|
1077
1077
|
in: in_,
|
|
1078
1078
|
out,
|
|
1079
|
-
...util.normalizeParams(params),
|
|
1079
|
+
...core_1.util.normalizeParams(params),
|
|
1080
1080
|
});
|
|
1081
1081
|
}
|
|
1082
1082
|
exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
|
|
@@ -1087,7 +1087,7 @@ function readonly(innerType, params) {
|
|
|
1087
1087
|
return new exports.ZodReadonly({
|
|
1088
1088
|
type: "readonly",
|
|
1089
1089
|
innerType,
|
|
1090
|
-
...util.normalizeParams(params),
|
|
1090
|
+
...core_1.util.normalizeParams(params),
|
|
1091
1091
|
});
|
|
1092
1092
|
}
|
|
1093
1093
|
exports.ZodTemplateLiteral = core.$constructor("ZodTemplateLiteral", (inst, def) => {
|
|
@@ -1098,7 +1098,7 @@ function templateLiteral(parts, params) {
|
|
|
1098
1098
|
return new exports.ZodTemplateLiteral({
|
|
1099
1099
|
type: "template_literal",
|
|
1100
1100
|
parts,
|
|
1101
|
-
...util.normalizeParams(params),
|
|
1101
|
+
...core_1.util.normalizeParams(params),
|
|
1102
1102
|
});
|
|
1103
1103
|
}
|
|
1104
1104
|
exports.ZodLazy = core.$constructor("ZodLazy", (inst, def) => {
|
|
@@ -1121,7 +1121,7 @@ function promise(innerType, params) {
|
|
|
1121
1121
|
return new exports.ZodPromise({
|
|
1122
1122
|
type: "promise",
|
|
1123
1123
|
innerType,
|
|
1124
|
-
...util.normalizeParams(params),
|
|
1124
|
+
...core_1.util.normalizeParams(params),
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
1127
|
exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
|
|
@@ -1132,7 +1132,7 @@ exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
|
|
|
1132
1132
|
function check(fn, params) {
|
|
1133
1133
|
const ch = new core.$ZodCheck({
|
|
1134
1134
|
check: "custom",
|
|
1135
|
-
...util.normalizeParams(params),
|
|
1135
|
+
...core_1.util.normalizeParams(params),
|
|
1136
1136
|
});
|
|
1137
1137
|
ch._zod.check = fn;
|
|
1138
1138
|
return ch;
|
|
@@ -1148,7 +1148,7 @@ function superRefine(fn, params) {
|
|
|
1148
1148
|
const ch = check((payload) => {
|
|
1149
1149
|
payload.addIssue = (issue) => {
|
|
1150
1150
|
if (typeof issue === "string") {
|
|
1151
|
-
payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
|
|
1151
|
+
payload.issues.push(core_1.util.issue(issue, payload.value, ch._zod.def));
|
|
1152
1152
|
}
|
|
1153
1153
|
else {
|
|
1154
1154
|
// for Zod 3 backwards compatibility
|
|
@@ -1159,7 +1159,7 @@ function superRefine(fn, params) {
|
|
|
1159
1159
|
_issue.input ?? (_issue.input = payload.value);
|
|
1160
1160
|
_issue.inst ?? (_issue.inst = ch);
|
|
1161
1161
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
1162
|
-
payload.issues.push(util.issue(_issue));
|
|
1162
|
+
payload.issues.push(core_1.util.issue(_issue));
|
|
1163
1163
|
}
|
|
1164
1164
|
};
|
|
1165
1165
|
return fn(payload.value, payload);
|
|
@@ -1178,7 +1178,7 @@ function _instanceof(cls, params = {
|
|
|
1178
1178
|
check: "custom",
|
|
1179
1179
|
fn: (data) => data instanceof cls,
|
|
1180
1180
|
abort: true,
|
|
1181
|
-
...util.normalizeParams(params),
|
|
1181
|
+
...core_1.util.normalizeParams(params),
|
|
1182
1182
|
});
|
|
1183
1183
|
}
|
|
1184
1184
|
// stringbool
|
package/dist/esm/schemas.d.ts
CHANGED
package/dist/esm/schemas.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.20250410T230029",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Colin McDonnell <zod@colinhacks.com>",
|
|
6
6
|
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@zod/core": "0.3.
|
|
73
|
+
"@zod/core": "0.3.2"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"clean": "rm -rf dist",
|
package/src/errors.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as core from "@zod/core";
|
|
2
2
|
import { $ZodError } from "@zod/core";
|
|
3
|
-
import type {
|
|
3
|
+
import type { util } from "@zod/core";
|
|
4
4
|
|
|
5
5
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
6
6
|
export type ZodIssue = core.$ZodIssue;
|
|
@@ -10,14 +10,14 @@ export class ZodError<T = unknown> extends $ZodError<T> {
|
|
|
10
10
|
format(): core.$ZodFormattedError<T>;
|
|
11
11
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
12
12
|
format<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFormattedError<T, U>;
|
|
13
|
-
format(mapper?: AnyFunc): any {
|
|
13
|
+
format(mapper?: util.AnyFunc): any {
|
|
14
14
|
return core.formatError(this, mapper);
|
|
15
15
|
}
|
|
16
16
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
17
17
|
flatten(): core.$ZodFlattenedError<T>;
|
|
18
18
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
19
19
|
flatten<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFlattenedError<T, U>;
|
|
20
|
-
flatten(mapper?: AnyFunc): core.$ZodFlattenedError<T> {
|
|
20
|
+
flatten(mapper?: util.AnyFunc): core.$ZodFlattenedError<T> {
|
|
21
21
|
return core.flattenError(this, mapper);
|
|
22
22
|
}
|
|
23
23
|
/** @deprecated Push directly to `.issues` instead. */
|
package/src/schemas.ts
CHANGED