zod 3.25.49 → 3.25.50
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/cjs/v4/classic/schemas.js +23 -22
- package/dist/cjs/v4/core/checks.js +2 -0
- package/dist/cjs/v4/core/core.js +2 -1
- package/dist/cjs/v4/core/schemas.js +1 -0
- package/dist/cjs/v4/mini/schemas.js +21 -27
- package/dist/esm/v4/classic/schemas.js +23 -22
- package/dist/esm/v4/core/checks.js +2 -0
- package/dist/esm/v4/core/core.js +2 -1
- package/dist/esm/v4/core/schemas.js +1 -0
- package/dist/esm/v4/mini/schemas.js +21 -27
- package/dist/types/v4/classic/coerce.d.ts +5 -5
- package/dist/types/v4/classic/schemas.d.ts +84 -118
- package/dist/types/v4/core/core.d.ts +3 -11
- package/dist/types/v4/core/schemas.d.ts +121 -108
- package/dist/types/v4/core/util.d.ts +2 -3
- package/dist/types/v4/mini/schemas.d.ts +31 -32
- package/package.json +1 -1
|
@@ -586,7 +586,7 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
|
586
586
|
return Object.fromEntries(Object.entries(inst._zod.def.shape));
|
|
587
587
|
});
|
|
588
588
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
589
|
-
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
589
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
590
590
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
591
591
|
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
592
592
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
@@ -644,7 +644,7 @@ exports.ZodUnion = core.$constructor("ZodUnion", (inst, def) => {
|
|
|
644
644
|
function union(options, params) {
|
|
645
645
|
return new exports.ZodUnion({
|
|
646
646
|
type: "union",
|
|
647
|
-
options,
|
|
647
|
+
options: options,
|
|
648
648
|
...core_1.util.normalizeParams(params),
|
|
649
649
|
});
|
|
650
650
|
}
|
|
@@ -668,8 +668,8 @@ exports.ZodIntersection = core.$constructor("ZodIntersection", (inst, def) => {
|
|
|
668
668
|
function intersection(left, right) {
|
|
669
669
|
return new exports.ZodIntersection({
|
|
670
670
|
type: "intersection",
|
|
671
|
-
left,
|
|
672
|
-
right,
|
|
671
|
+
left: left,
|
|
672
|
+
right: right,
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
675
|
exports.ZodTuple = core.$constructor("ZodTuple", (inst, def) => {
|
|
@@ -677,7 +677,7 @@ exports.ZodTuple = core.$constructor("ZodTuple", (inst, def) => {
|
|
|
677
677
|
exports.ZodType.init(inst, def);
|
|
678
678
|
inst.rest = (rest) => inst.clone({
|
|
679
679
|
...inst._zod.def,
|
|
680
|
-
rest,
|
|
680
|
+
rest: rest,
|
|
681
681
|
});
|
|
682
682
|
});
|
|
683
683
|
function tuple(items, _paramsOrRest, _params) {
|
|
@@ -686,7 +686,7 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
686
686
|
const rest = hasRest ? _paramsOrRest : null;
|
|
687
687
|
return new exports.ZodTuple({
|
|
688
688
|
type: "tuple",
|
|
689
|
-
items,
|
|
689
|
+
items: items,
|
|
690
690
|
rest,
|
|
691
691
|
...core_1.util.normalizeParams(params),
|
|
692
692
|
});
|
|
@@ -701,15 +701,16 @@ function record(keyType, valueType, params) {
|
|
|
701
701
|
return new exports.ZodRecord({
|
|
702
702
|
type: "record",
|
|
703
703
|
keyType,
|
|
704
|
-
valueType,
|
|
704
|
+
valueType: valueType,
|
|
705
705
|
...core_1.util.normalizeParams(params),
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
|
+
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
708
709
|
function partialRecord(keyType, valueType, params) {
|
|
709
710
|
return new exports.ZodRecord({
|
|
710
711
|
type: "record",
|
|
711
712
|
keyType: union([keyType, never()]),
|
|
712
|
-
valueType,
|
|
713
|
+
valueType: valueType,
|
|
713
714
|
...core_1.util.normalizeParams(params),
|
|
714
715
|
});
|
|
715
716
|
}
|
|
@@ -722,8 +723,8 @@ exports.ZodMap = core.$constructor("ZodMap", (inst, def) => {
|
|
|
722
723
|
function map(keyType, valueType, params) {
|
|
723
724
|
return new exports.ZodMap({
|
|
724
725
|
type: "map",
|
|
725
|
-
keyType,
|
|
726
|
-
valueType,
|
|
726
|
+
keyType: keyType,
|
|
727
|
+
valueType: valueType,
|
|
727
728
|
...core_1.util.normalizeParams(params),
|
|
728
729
|
});
|
|
729
730
|
}
|
|
@@ -738,7 +739,7 @@ exports.ZodSet = core.$constructor("ZodSet", (inst, def) => {
|
|
|
738
739
|
function set(valueType, params) {
|
|
739
740
|
return new exports.ZodSet({
|
|
740
741
|
type: "set",
|
|
741
|
-
valueType,
|
|
742
|
+
valueType: valueType,
|
|
742
743
|
...core_1.util.normalizeParams(params),
|
|
743
744
|
});
|
|
744
745
|
}
|
|
@@ -878,7 +879,7 @@ exports.ZodOptional = core.$constructor("ZodOptional", (inst, def) => {
|
|
|
878
879
|
function optional(innerType) {
|
|
879
880
|
return new exports.ZodOptional({
|
|
880
881
|
type: "optional",
|
|
881
|
-
innerType,
|
|
882
|
+
innerType: innerType,
|
|
882
883
|
});
|
|
883
884
|
}
|
|
884
885
|
exports.ZodNullable = core.$constructor("ZodNullable", (inst, def) => {
|
|
@@ -889,7 +890,7 @@ exports.ZodNullable = core.$constructor("ZodNullable", (inst, def) => {
|
|
|
889
890
|
function nullable(innerType) {
|
|
890
891
|
return new exports.ZodNullable({
|
|
891
892
|
type: "nullable",
|
|
892
|
-
innerType,
|
|
893
|
+
innerType: innerType,
|
|
893
894
|
});
|
|
894
895
|
}
|
|
895
896
|
// nullish
|
|
@@ -905,7 +906,7 @@ exports.ZodDefault = core.$constructor("ZodDefault", (inst, def) => {
|
|
|
905
906
|
function _default(innerType, defaultValue) {
|
|
906
907
|
return new exports.ZodDefault({
|
|
907
908
|
type: "default",
|
|
908
|
-
innerType,
|
|
909
|
+
innerType: innerType,
|
|
909
910
|
get defaultValue() {
|
|
910
911
|
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
911
912
|
},
|
|
@@ -919,7 +920,7 @@ exports.ZodPrefault = core.$constructor("ZodPrefault", (inst, def) => {
|
|
|
919
920
|
function prefault(innerType, defaultValue) {
|
|
920
921
|
return new exports.ZodPrefault({
|
|
921
922
|
type: "prefault",
|
|
922
|
-
innerType,
|
|
923
|
+
innerType: innerType,
|
|
923
924
|
get defaultValue() {
|
|
924
925
|
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
925
926
|
},
|
|
@@ -933,7 +934,7 @@ exports.ZodNonOptional = core.$constructor("ZodNonOptional", (inst, def) => {
|
|
|
933
934
|
function nonoptional(innerType, params) {
|
|
934
935
|
return new exports.ZodNonOptional({
|
|
935
936
|
type: "nonoptional",
|
|
936
|
-
innerType,
|
|
937
|
+
innerType: innerType,
|
|
937
938
|
...core_1.util.normalizeParams(params),
|
|
938
939
|
});
|
|
939
940
|
}
|
|
@@ -945,7 +946,7 @@ exports.ZodSuccess = core.$constructor("ZodSuccess", (inst, def) => {
|
|
|
945
946
|
function success(innerType) {
|
|
946
947
|
return new exports.ZodSuccess({
|
|
947
948
|
type: "success",
|
|
948
|
-
innerType,
|
|
949
|
+
innerType: innerType,
|
|
949
950
|
});
|
|
950
951
|
}
|
|
951
952
|
exports.ZodCatch = core.$constructor("ZodCatch", (inst, def) => {
|
|
@@ -957,7 +958,7 @@ exports.ZodCatch = core.$constructor("ZodCatch", (inst, def) => {
|
|
|
957
958
|
function _catch(innerType, catchValue) {
|
|
958
959
|
return new exports.ZodCatch({
|
|
959
960
|
type: "catch",
|
|
960
|
-
innerType,
|
|
961
|
+
innerType: innerType,
|
|
961
962
|
catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
|
|
962
963
|
});
|
|
963
964
|
}
|
|
@@ -978,7 +979,7 @@ function pipe(in_, out) {
|
|
|
978
979
|
return new exports.ZodPipe({
|
|
979
980
|
type: "pipe",
|
|
980
981
|
in: in_,
|
|
981
|
-
out,
|
|
982
|
+
out: out,
|
|
982
983
|
// ...util.normalizeParams(params),
|
|
983
984
|
});
|
|
984
985
|
}
|
|
@@ -989,7 +990,7 @@ exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
|
|
|
989
990
|
function readonly(innerType) {
|
|
990
991
|
return new exports.ZodReadonly({
|
|
991
992
|
type: "readonly",
|
|
992
|
-
innerType,
|
|
993
|
+
innerType: innerType,
|
|
993
994
|
});
|
|
994
995
|
}
|
|
995
996
|
exports.ZodTemplateLiteral = core.$constructor("ZodTemplateLiteral", (inst, def) => {
|
|
@@ -1011,7 +1012,7 @@ exports.ZodLazy = core.$constructor("ZodLazy", (inst, def) => {
|
|
|
1011
1012
|
function lazy(getter) {
|
|
1012
1013
|
return new exports.ZodLazy({
|
|
1013
1014
|
type: "lazy",
|
|
1014
|
-
getter,
|
|
1015
|
+
getter: getter,
|
|
1015
1016
|
});
|
|
1016
1017
|
}
|
|
1017
1018
|
exports.ZodPromise = core.$constructor("ZodPromise", (inst, def) => {
|
|
@@ -1022,7 +1023,7 @@ exports.ZodPromise = core.$constructor("ZodPromise", (inst, def) => {
|
|
|
1022
1023
|
function promise(innerType) {
|
|
1023
1024
|
return new exports.ZodPromise({
|
|
1024
1025
|
type: "promise",
|
|
1025
|
-
innerType,
|
|
1026
|
+
innerType: innerType,
|
|
1026
1027
|
});
|
|
1027
1028
|
}
|
|
1028
1029
|
exports.ZodCustom = core.$constructor("ZodCustom", (inst, def) => {
|
|
@@ -347,6 +347,7 @@ exports.$ZodCheckMaxLength = core.$constructor("$ZodCheckMaxLength", (inst, def)
|
|
|
347
347
|
origin,
|
|
348
348
|
code: "too_big",
|
|
349
349
|
maximum: def.maximum,
|
|
350
|
+
inclusive: true,
|
|
350
351
|
input,
|
|
351
352
|
inst,
|
|
352
353
|
continue: !def.abort,
|
|
@@ -374,6 +375,7 @@ exports.$ZodCheckMinLength = core.$constructor("$ZodCheckMinLength", (inst, def)
|
|
|
374
375
|
origin,
|
|
375
376
|
code: "too_small",
|
|
376
377
|
minimum: def.minimum,
|
|
378
|
+
inclusive: true,
|
|
377
379
|
input,
|
|
378
380
|
inst,
|
|
379
381
|
continue: !def.abort,
|
package/dist/cjs/v4/core/core.js
CHANGED
|
@@ -15,7 +15,8 @@ function $constructor(name, initializer, params) {
|
|
|
15
15
|
initializer(inst, def);
|
|
16
16
|
// support prototype modifications
|
|
17
17
|
for (const k in _.prototype) {
|
|
18
|
-
|
|
18
|
+
if (!(k in inst))
|
|
19
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
19
20
|
}
|
|
20
21
|
inst._zod.constr = _;
|
|
21
22
|
inst._zod.def = def;
|
|
@@ -687,6 +687,7 @@ function handleOptionalObjectResult(result, final, key, input) {
|
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
689
|
exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
690
|
+
// requires cast because technically $ZodObject doesn't extend
|
|
690
691
|
exports.$ZodType.init(inst, def);
|
|
691
692
|
const _normalized = util.cached(() => {
|
|
692
693
|
const keys = Object.keys(def.shape);
|
|
@@ -414,10 +414,7 @@ exports.ZodMiniArray = core.$constructor("ZodMiniArray", (inst, def) => {
|
|
|
414
414
|
function array(element, params) {
|
|
415
415
|
return new exports.ZodMiniArray({
|
|
416
416
|
type: "array",
|
|
417
|
-
element,
|
|
418
|
-
// get element() {
|
|
419
|
-
// return element;
|
|
420
|
-
// },
|
|
417
|
+
element: element,
|
|
421
418
|
...core_1.util.normalizeParams(params),
|
|
422
419
|
});
|
|
423
420
|
}
|
|
@@ -450,9 +447,6 @@ function strictObject(shape, params) {
|
|
|
450
447
|
core_1.util.assignProp(this, "shape", { ...shape });
|
|
451
448
|
return this.shape;
|
|
452
449
|
},
|
|
453
|
-
// get optional() {
|
|
454
|
-
// return util.optionalKeys(shape);
|
|
455
|
-
// },
|
|
456
450
|
catchall: never(),
|
|
457
451
|
...core_1.util.normalizeParams(params),
|
|
458
452
|
});
|
|
@@ -500,7 +494,7 @@ exports.ZodMiniUnion = core.$constructor("ZodMiniUnion", (inst, def) => {
|
|
|
500
494
|
function union(options, params) {
|
|
501
495
|
return new exports.ZodMiniUnion({
|
|
502
496
|
type: "union",
|
|
503
|
-
options,
|
|
497
|
+
options: options,
|
|
504
498
|
...core_1.util.normalizeParams(params),
|
|
505
499
|
});
|
|
506
500
|
}
|
|
@@ -523,8 +517,8 @@ exports.ZodMiniIntersection = core.$constructor("ZodMiniIntersection", (inst, de
|
|
|
523
517
|
function intersection(left, right) {
|
|
524
518
|
return new exports.ZodMiniIntersection({
|
|
525
519
|
type: "intersection",
|
|
526
|
-
left,
|
|
527
|
-
right,
|
|
520
|
+
left: left,
|
|
521
|
+
right: right,
|
|
528
522
|
});
|
|
529
523
|
}
|
|
530
524
|
exports.ZodMiniTuple = core.$constructor("ZodMiniTuple", (inst, def) => {
|
|
@@ -537,7 +531,7 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
537
531
|
const rest = hasRest ? _paramsOrRest : null;
|
|
538
532
|
return new exports.ZodMiniTuple({
|
|
539
533
|
type: "tuple",
|
|
540
|
-
items,
|
|
534
|
+
items: items,
|
|
541
535
|
rest,
|
|
542
536
|
...core_1.util.normalizeParams(params),
|
|
543
537
|
});
|
|
@@ -550,7 +544,7 @@ function record(keyType, valueType, params) {
|
|
|
550
544
|
return new exports.ZodMiniRecord({
|
|
551
545
|
type: "record",
|
|
552
546
|
keyType,
|
|
553
|
-
valueType,
|
|
547
|
+
valueType: valueType,
|
|
554
548
|
...core_1.util.normalizeParams(params),
|
|
555
549
|
});
|
|
556
550
|
}
|
|
@@ -558,7 +552,7 @@ function partialRecord(keyType, valueType, params) {
|
|
|
558
552
|
return new exports.ZodMiniRecord({
|
|
559
553
|
type: "record",
|
|
560
554
|
keyType: union([keyType, never()]),
|
|
561
|
-
valueType,
|
|
555
|
+
valueType: valueType,
|
|
562
556
|
...core_1.util.normalizeParams(params),
|
|
563
557
|
});
|
|
564
558
|
}
|
|
@@ -569,8 +563,8 @@ exports.ZodMiniMap = core.$constructor("ZodMiniMap", (inst, def) => {
|
|
|
569
563
|
function map(keyType, valueType, params) {
|
|
570
564
|
return new exports.ZodMiniMap({
|
|
571
565
|
type: "map",
|
|
572
|
-
keyType,
|
|
573
|
-
valueType,
|
|
566
|
+
keyType: keyType,
|
|
567
|
+
valueType: valueType,
|
|
574
568
|
...core_1.util.normalizeParams(params),
|
|
575
569
|
});
|
|
576
570
|
}
|
|
@@ -581,7 +575,7 @@ exports.ZodMiniSet = core.$constructor("ZodMiniSet", (inst, def) => {
|
|
|
581
575
|
function set(valueType, params) {
|
|
582
576
|
return new exports.ZodMiniSet({
|
|
583
577
|
type: "set",
|
|
584
|
-
valueType,
|
|
578
|
+
valueType: valueType,
|
|
585
579
|
...core_1.util.normalizeParams(params),
|
|
586
580
|
});
|
|
587
581
|
}
|
|
@@ -646,7 +640,7 @@ exports.ZodMiniOptional = core.$constructor("ZodMiniOptional", (inst, def) => {
|
|
|
646
640
|
function optional(innerType) {
|
|
647
641
|
return new exports.ZodMiniOptional({
|
|
648
642
|
type: "optional",
|
|
649
|
-
innerType,
|
|
643
|
+
innerType: innerType,
|
|
650
644
|
});
|
|
651
645
|
}
|
|
652
646
|
exports.ZodMiniNullable = core.$constructor("ZodMiniNullable", (inst, def) => {
|
|
@@ -656,7 +650,7 @@ exports.ZodMiniNullable = core.$constructor("ZodMiniNullable", (inst, def) => {
|
|
|
656
650
|
function nullable(innerType) {
|
|
657
651
|
return new exports.ZodMiniNullable({
|
|
658
652
|
type: "nullable",
|
|
659
|
-
innerType,
|
|
653
|
+
innerType: innerType,
|
|
660
654
|
});
|
|
661
655
|
}
|
|
662
656
|
// nullish
|
|
@@ -670,7 +664,7 @@ exports.ZodMiniDefault = core.$constructor("ZodMiniDefault", (inst, def) => {
|
|
|
670
664
|
function _default(innerType, defaultValue) {
|
|
671
665
|
return new exports.ZodMiniDefault({
|
|
672
666
|
type: "default",
|
|
673
|
-
innerType,
|
|
667
|
+
innerType: innerType,
|
|
674
668
|
get defaultValue() {
|
|
675
669
|
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
676
670
|
},
|
|
@@ -683,7 +677,7 @@ exports.ZodMiniPrefault = core.$constructor("ZodMiniPrefault", (inst, def) => {
|
|
|
683
677
|
function prefault(innerType, defaultValue) {
|
|
684
678
|
return new exports.ZodMiniPrefault({
|
|
685
679
|
type: "prefault",
|
|
686
|
-
innerType,
|
|
680
|
+
innerType: innerType,
|
|
687
681
|
get defaultValue() {
|
|
688
682
|
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
689
683
|
},
|
|
@@ -696,7 +690,7 @@ exports.ZodMiniNonOptional = core.$constructor("ZodMiniNonOptional", (inst, def)
|
|
|
696
690
|
function nonoptional(innerType, params) {
|
|
697
691
|
return new exports.ZodMiniNonOptional({
|
|
698
692
|
type: "nonoptional",
|
|
699
|
-
innerType,
|
|
693
|
+
innerType: innerType,
|
|
700
694
|
...core_1.util.normalizeParams(params),
|
|
701
695
|
});
|
|
702
696
|
}
|
|
@@ -707,7 +701,7 @@ exports.ZodMiniSuccess = core.$constructor("ZodMiniSuccess", (inst, def) => {
|
|
|
707
701
|
function success(innerType) {
|
|
708
702
|
return new exports.ZodMiniSuccess({
|
|
709
703
|
type: "success",
|
|
710
|
-
innerType,
|
|
704
|
+
innerType: innerType,
|
|
711
705
|
});
|
|
712
706
|
}
|
|
713
707
|
exports.ZodMiniCatch = core.$constructor("ZodMiniCatch", (inst, def) => {
|
|
@@ -717,7 +711,7 @@ exports.ZodMiniCatch = core.$constructor("ZodMiniCatch", (inst, def) => {
|
|
|
717
711
|
function _catch(innerType, catchValue) {
|
|
718
712
|
return new exports.ZodMiniCatch({
|
|
719
713
|
type: "catch",
|
|
720
|
-
innerType,
|
|
714
|
+
innerType: innerType,
|
|
721
715
|
catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
|
|
722
716
|
});
|
|
723
717
|
}
|
|
@@ -736,7 +730,7 @@ function pipe(in_, out) {
|
|
|
736
730
|
return new exports.ZodMiniPipe({
|
|
737
731
|
type: "pipe",
|
|
738
732
|
in: in_,
|
|
739
|
-
out,
|
|
733
|
+
out: out,
|
|
740
734
|
});
|
|
741
735
|
}
|
|
742
736
|
exports.ZodMiniReadonly = core.$constructor("ZodMiniReadonly", (inst, def) => {
|
|
@@ -746,7 +740,7 @@ exports.ZodMiniReadonly = core.$constructor("ZodMiniReadonly", (inst, def) => {
|
|
|
746
740
|
function readonly(innerType) {
|
|
747
741
|
return new exports.ZodMiniReadonly({
|
|
748
742
|
type: "readonly",
|
|
749
|
-
innerType,
|
|
743
|
+
innerType: innerType,
|
|
750
744
|
});
|
|
751
745
|
}
|
|
752
746
|
exports.ZodMiniTemplateLiteral = core.$constructor("ZodMiniTemplateLiteral", (inst, def) => {
|
|
@@ -770,7 +764,7 @@ exports.ZodMiniLazy = core.$constructor("ZodMiniLazy", (inst, def) => {
|
|
|
770
764
|
function _lazy(getter) {
|
|
771
765
|
return new exports.ZodMiniLazy({
|
|
772
766
|
type: "lazy",
|
|
773
|
-
getter,
|
|
767
|
+
getter: getter,
|
|
774
768
|
});
|
|
775
769
|
}
|
|
776
770
|
exports.ZodMiniPromise = core.$constructor("ZodMiniPromise", (inst, def) => {
|
|
@@ -780,7 +774,7 @@ exports.ZodMiniPromise = core.$constructor("ZodMiniPromise", (inst, def) => {
|
|
|
780
774
|
function promise(innerType) {
|
|
781
775
|
return new exports.ZodMiniPromise({
|
|
782
776
|
type: "promise",
|
|
783
|
-
innerType,
|
|
777
|
+
innerType: innerType,
|
|
784
778
|
});
|
|
785
779
|
}
|
|
786
780
|
exports.ZodMiniCustom = core.$constructor("ZodMiniCustom", (inst, def) => {
|
|
@@ -482,7 +482,7 @@ export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def
|
|
|
482
482
|
return Object.fromEntries(Object.entries(inst._zod.def.shape));
|
|
483
483
|
});
|
|
484
484
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
485
|
-
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
485
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
486
486
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
487
487
|
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
488
488
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
@@ -540,7 +540,7 @@ export const ZodUnion = /*@__PURE__*/ core.$constructor("ZodUnion", (inst, def)
|
|
|
540
540
|
export function union(options, params) {
|
|
541
541
|
return new ZodUnion({
|
|
542
542
|
type: "union",
|
|
543
|
-
options,
|
|
543
|
+
options: options,
|
|
544
544
|
...util.normalizeParams(params),
|
|
545
545
|
});
|
|
546
546
|
}
|
|
@@ -564,8 +564,8 @@ export const ZodIntersection = /*@__PURE__*/ core.$constructor("ZodIntersection"
|
|
|
564
564
|
export function intersection(left, right) {
|
|
565
565
|
return new ZodIntersection({
|
|
566
566
|
type: "intersection",
|
|
567
|
-
left,
|
|
568
|
-
right,
|
|
567
|
+
left: left,
|
|
568
|
+
right: right,
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
571
|
export const ZodTuple = /*@__PURE__*/ core.$constructor("ZodTuple", (inst, def) => {
|
|
@@ -573,7 +573,7 @@ export const ZodTuple = /*@__PURE__*/ core.$constructor("ZodTuple", (inst, def)
|
|
|
573
573
|
ZodType.init(inst, def);
|
|
574
574
|
inst.rest = (rest) => inst.clone({
|
|
575
575
|
...inst._zod.def,
|
|
576
|
-
rest,
|
|
576
|
+
rest: rest,
|
|
577
577
|
});
|
|
578
578
|
});
|
|
579
579
|
export function tuple(items, _paramsOrRest, _params) {
|
|
@@ -582,7 +582,7 @@ export function tuple(items, _paramsOrRest, _params) {
|
|
|
582
582
|
const rest = hasRest ? _paramsOrRest : null;
|
|
583
583
|
return new ZodTuple({
|
|
584
584
|
type: "tuple",
|
|
585
|
-
items,
|
|
585
|
+
items: items,
|
|
586
586
|
rest,
|
|
587
587
|
...util.normalizeParams(params),
|
|
588
588
|
});
|
|
@@ -597,15 +597,16 @@ export function record(keyType, valueType, params) {
|
|
|
597
597
|
return new ZodRecord({
|
|
598
598
|
type: "record",
|
|
599
599
|
keyType,
|
|
600
|
-
valueType,
|
|
600
|
+
valueType: valueType,
|
|
601
601
|
...util.normalizeParams(params),
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
|
+
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
604
605
|
export function partialRecord(keyType, valueType, params) {
|
|
605
606
|
return new ZodRecord({
|
|
606
607
|
type: "record",
|
|
607
608
|
keyType: union([keyType, never()]),
|
|
608
|
-
valueType,
|
|
609
|
+
valueType: valueType,
|
|
609
610
|
...util.normalizeParams(params),
|
|
610
611
|
});
|
|
611
612
|
}
|
|
@@ -618,8 +619,8 @@ export const ZodMap = /*@__PURE__*/ core.$constructor("ZodMap", (inst, def) => {
|
|
|
618
619
|
export function map(keyType, valueType, params) {
|
|
619
620
|
return new ZodMap({
|
|
620
621
|
type: "map",
|
|
621
|
-
keyType,
|
|
622
|
-
valueType,
|
|
622
|
+
keyType: keyType,
|
|
623
|
+
valueType: valueType,
|
|
623
624
|
...util.normalizeParams(params),
|
|
624
625
|
});
|
|
625
626
|
}
|
|
@@ -634,7 +635,7 @@ export const ZodSet = /*@__PURE__*/ core.$constructor("ZodSet", (inst, def) => {
|
|
|
634
635
|
export function set(valueType, params) {
|
|
635
636
|
return new ZodSet({
|
|
636
637
|
type: "set",
|
|
637
|
-
valueType,
|
|
638
|
+
valueType: valueType,
|
|
638
639
|
...util.normalizeParams(params),
|
|
639
640
|
});
|
|
640
641
|
}
|
|
@@ -775,7 +776,7 @@ export const ZodOptional = /*@__PURE__*/ core.$constructor("ZodOptional", (inst,
|
|
|
775
776
|
export function optional(innerType) {
|
|
776
777
|
return new ZodOptional({
|
|
777
778
|
type: "optional",
|
|
778
|
-
innerType,
|
|
779
|
+
innerType: innerType,
|
|
779
780
|
});
|
|
780
781
|
}
|
|
781
782
|
export const ZodNullable = /*@__PURE__*/ core.$constructor("ZodNullable", (inst, def) => {
|
|
@@ -786,7 +787,7 @@ export const ZodNullable = /*@__PURE__*/ core.$constructor("ZodNullable", (inst,
|
|
|
786
787
|
export function nullable(innerType) {
|
|
787
788
|
return new ZodNullable({
|
|
788
789
|
type: "nullable",
|
|
789
|
-
innerType,
|
|
790
|
+
innerType: innerType,
|
|
790
791
|
});
|
|
791
792
|
}
|
|
792
793
|
// nullish
|
|
@@ -802,7 +803,7 @@ export const ZodDefault = /*@__PURE__*/ core.$constructor("ZodDefault", (inst, d
|
|
|
802
803
|
export function _default(innerType, defaultValue) {
|
|
803
804
|
return new ZodDefault({
|
|
804
805
|
type: "default",
|
|
805
|
-
innerType,
|
|
806
|
+
innerType: innerType,
|
|
806
807
|
get defaultValue() {
|
|
807
808
|
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
808
809
|
},
|
|
@@ -816,7 +817,7 @@ export const ZodPrefault = /*@__PURE__*/ core.$constructor("ZodPrefault", (inst,
|
|
|
816
817
|
export function prefault(innerType, defaultValue) {
|
|
817
818
|
return new ZodPrefault({
|
|
818
819
|
type: "prefault",
|
|
819
|
-
innerType,
|
|
820
|
+
innerType: innerType,
|
|
820
821
|
get defaultValue() {
|
|
821
822
|
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
822
823
|
},
|
|
@@ -830,7 +831,7 @@ export const ZodNonOptional = /*@__PURE__*/ core.$constructor("ZodNonOptional",
|
|
|
830
831
|
export function nonoptional(innerType, params) {
|
|
831
832
|
return new ZodNonOptional({
|
|
832
833
|
type: "nonoptional",
|
|
833
|
-
innerType,
|
|
834
|
+
innerType: innerType,
|
|
834
835
|
...util.normalizeParams(params),
|
|
835
836
|
});
|
|
836
837
|
}
|
|
@@ -842,7 +843,7 @@ export const ZodSuccess = /*@__PURE__*/ core.$constructor("ZodSuccess", (inst, d
|
|
|
842
843
|
export function success(innerType) {
|
|
843
844
|
return new ZodSuccess({
|
|
844
845
|
type: "success",
|
|
845
|
-
innerType,
|
|
846
|
+
innerType: innerType,
|
|
846
847
|
});
|
|
847
848
|
}
|
|
848
849
|
export const ZodCatch = /*@__PURE__*/ core.$constructor("ZodCatch", (inst, def) => {
|
|
@@ -854,7 +855,7 @@ export const ZodCatch = /*@__PURE__*/ core.$constructor("ZodCatch", (inst, def)
|
|
|
854
855
|
function _catch(innerType, catchValue) {
|
|
855
856
|
return new ZodCatch({
|
|
856
857
|
type: "catch",
|
|
857
|
-
innerType,
|
|
858
|
+
innerType: innerType,
|
|
858
859
|
catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
|
|
859
860
|
});
|
|
860
861
|
}
|
|
@@ -876,7 +877,7 @@ export function pipe(in_, out) {
|
|
|
876
877
|
return new ZodPipe({
|
|
877
878
|
type: "pipe",
|
|
878
879
|
in: in_,
|
|
879
|
-
out,
|
|
880
|
+
out: out,
|
|
880
881
|
// ...util.normalizeParams(params),
|
|
881
882
|
});
|
|
882
883
|
}
|
|
@@ -887,7 +888,7 @@ export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst,
|
|
|
887
888
|
export function readonly(innerType) {
|
|
888
889
|
return new ZodReadonly({
|
|
889
890
|
type: "readonly",
|
|
890
|
-
innerType,
|
|
891
|
+
innerType: innerType,
|
|
891
892
|
});
|
|
892
893
|
}
|
|
893
894
|
export const ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("ZodTemplateLiteral", (inst, def) => {
|
|
@@ -909,7 +910,7 @@ export const ZodLazy = /*@__PURE__*/ core.$constructor("ZodLazy", (inst, def) =>
|
|
|
909
910
|
export function lazy(getter) {
|
|
910
911
|
return new ZodLazy({
|
|
911
912
|
type: "lazy",
|
|
912
|
-
getter,
|
|
913
|
+
getter: getter,
|
|
913
914
|
});
|
|
914
915
|
}
|
|
915
916
|
export const ZodPromise = /*@__PURE__*/ core.$constructor("ZodPromise", (inst, def) => {
|
|
@@ -920,7 +921,7 @@ export const ZodPromise = /*@__PURE__*/ core.$constructor("ZodPromise", (inst, d
|
|
|
920
921
|
export function promise(innerType) {
|
|
921
922
|
return new ZodPromise({
|
|
922
923
|
type: "promise",
|
|
923
|
-
innerType,
|
|
924
|
+
innerType: innerType,
|
|
924
925
|
});
|
|
925
926
|
}
|
|
926
927
|
export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
|
|
@@ -321,6 +321,7 @@ export const $ZodCheckMaxLength = /*@__PURE__*/ core.$constructor("$ZodCheckMaxL
|
|
|
321
321
|
origin,
|
|
322
322
|
code: "too_big",
|
|
323
323
|
maximum: def.maximum,
|
|
324
|
+
inclusive: true,
|
|
324
325
|
input,
|
|
325
326
|
inst,
|
|
326
327
|
continue: !def.abort,
|
|
@@ -348,6 +349,7 @@ export const $ZodCheckMinLength = /*@__PURE__*/ core.$constructor("$ZodCheckMinL
|
|
|
348
349
|
origin,
|
|
349
350
|
code: "too_small",
|
|
350
351
|
minimum: def.minimum,
|
|
352
|
+
inclusive: true,
|
|
351
353
|
input,
|
|
352
354
|
inst,
|
|
353
355
|
continue: !def.abort,
|
package/dist/esm/v4/core/core.js
CHANGED
|
@@ -10,7 +10,8 @@ export /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params)
|
|
|
10
10
|
initializer(inst, def);
|
|
11
11
|
// support prototype modifications
|
|
12
12
|
for (const k in _.prototype) {
|
|
13
|
-
|
|
13
|
+
if (!(k in inst))
|
|
14
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
14
15
|
}
|
|
15
16
|
inst._zod.constr = _;
|
|
16
17
|
inst._zod.def = def;
|
|
@@ -656,6 +656,7 @@ function handleOptionalObjectResult(result, final, key, input) {
|
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
|
659
|
+
// requires cast because technically $ZodObject doesn't extend
|
|
659
660
|
$ZodType.init(inst, def);
|
|
660
661
|
const _normalized = util.cached(() => {
|
|
661
662
|
const keys = Object.keys(def.shape);
|