zod 3.26.0-canary.20250703T013930 → 3.26.0-canary.20250703T025502
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 +20 -20
- package/src/index.ts +4 -0
- package/src/v3/ZodError.ts +330 -0
- package/src/v3/benchmarks/datetime.ts +58 -0
- package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/src/v3/benchmarks/index.ts +59 -0
- package/src/v3/benchmarks/ipv4.ts +57 -0
- package/src/v3/benchmarks/object.ts +69 -0
- package/src/v3/benchmarks/primitives.ts +162 -0
- package/src/v3/benchmarks/realworld.ts +63 -0
- package/src/v3/benchmarks/string.ts +55 -0
- package/src/v3/benchmarks/union.ts +80 -0
- package/src/v3/errors.ts +13 -0
- package/src/v3/external.ts +6 -0
- package/src/v3/helpers/enumUtil.ts +17 -0
- package/src/v3/helpers/errorUtil.ts +8 -0
- package/src/v3/helpers/parseUtil.ts +176 -0
- package/src/v3/helpers/partialUtil.ts +34 -0
- package/src/v3/helpers/typeAliases.ts +2 -0
- package/src/v3/helpers/util.ts +224 -0
- package/src/v3/index.ts +4 -0
- package/src/v3/locales/en.ts +124 -0
- package/src/v3/standard-schema.ts +113 -0
- package/src/v3/tests/Mocker.ts +54 -0
- package/src/v3/tests/all-errors.test.ts +157 -0
- package/src/v3/tests/anyunknown.test.ts +28 -0
- package/src/v3/tests/array.test.ts +71 -0
- package/src/v3/tests/async-parsing.test.ts +388 -0
- package/src/v3/tests/async-refinements.test.ts +46 -0
- package/src/v3/tests/base.test.ts +29 -0
- package/src/v3/tests/bigint.test.ts +55 -0
- package/src/v3/tests/branded.test.ts +53 -0
- package/src/v3/tests/catch.test.ts +220 -0
- package/src/v3/tests/coerce.test.ts +133 -0
- package/src/v3/tests/complex.test.ts +56 -0
- package/src/v3/tests/custom.test.ts +31 -0
- package/src/v3/tests/date.test.ts +32 -0
- package/src/v3/tests/deepmasking.test.ts +186 -0
- package/src/v3/tests/default.test.ts +112 -0
- package/src/v3/tests/description.test.ts +33 -0
- package/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/src/v3/tests/enum.test.ts +80 -0
- package/src/v3/tests/error.test.ts +551 -0
- package/src/v3/tests/firstparty.test.ts +87 -0
- package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/src/v3/tests/function.test.ts +257 -0
- package/src/v3/tests/generics.test.ts +48 -0
- package/src/v3/tests/instanceof.test.ts +37 -0
- package/src/v3/tests/intersection.test.ts +110 -0
- package/src/v3/tests/language-server.source.ts +76 -0
- package/src/v3/tests/language-server.test.ts +207 -0
- package/src/v3/tests/literal.test.ts +36 -0
- package/src/v3/tests/map.test.ts +110 -0
- package/src/v3/tests/masking.test.ts +4 -0
- package/src/v3/tests/mocker.test.ts +19 -0
- package/src/v3/tests/nan.test.ts +21 -0
- package/src/v3/tests/nativeEnum.test.ts +87 -0
- package/src/v3/tests/nullable.test.ts +42 -0
- package/src/v3/tests/number.test.ts +176 -0
- package/src/v3/tests/object-augmentation.test.ts +29 -0
- package/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/src/v3/tests/object.test.ts +434 -0
- package/src/v3/tests/optional.test.ts +42 -0
- package/src/v3/tests/parseUtil.test.ts +23 -0
- package/src/v3/tests/parser.test.ts +41 -0
- package/src/v3/tests/partials.test.ts +243 -0
- package/src/v3/tests/pickomit.test.ts +111 -0
- package/src/v3/tests/pipeline.test.ts +29 -0
- package/src/v3/tests/preprocess.test.ts +186 -0
- package/src/v3/tests/primitive.test.ts +440 -0
- package/src/v3/tests/promise.test.ts +90 -0
- package/src/v3/tests/readonly.test.ts +194 -0
- package/src/v3/tests/record.test.ts +171 -0
- package/src/v3/tests/recursive.test.ts +197 -0
- package/src/v3/tests/refine.test.ts +313 -0
- package/src/v3/tests/safeparse.test.ts +27 -0
- package/src/v3/tests/set.test.ts +142 -0
- package/src/v3/tests/standard-schema.test.ts +83 -0
- package/src/v3/tests/string.test.ts +916 -0
- package/src/v3/tests/transformer.test.ts +233 -0
- package/src/v3/tests/tuple.test.ts +90 -0
- package/src/v3/tests/unions.test.ts +57 -0
- package/src/v3/tests/validations.test.ts +133 -0
- package/src/v3/tests/void.test.ts +15 -0
- package/src/v3/types.ts +5136 -0
- package/src/v4/classic/checks.ts +30 -0
- package/src/v4/classic/coerce.ts +27 -0
- package/src/v4/classic/compat.ts +66 -0
- package/src/v4/classic/errors.ts +75 -0
- package/src/v4/classic/external.ts +50 -0
- package/src/v4/classic/index.ts +5 -0
- package/src/v4/classic/iso.ts +90 -0
- package/src/v4/classic/parse.ts +33 -0
- package/src/v4/classic/schemas.ts +2055 -0
- package/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/src/v4/classic/tests/array.test.ts +264 -0
- package/src/v4/classic/tests/assignability.test.ts +210 -0
- package/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/src/v4/classic/tests/base.test.ts +7 -0
- package/src/v4/classic/tests/bigint.test.ts +54 -0
- package/src/v4/classic/tests/brand.test.ts +65 -0
- package/src/v4/classic/tests/catch.test.ts +252 -0
- package/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/src/v4/classic/tests/coerce.test.ts +160 -0
- package/src/v4/classic/tests/continuability.test.ts +352 -0
- package/src/v4/classic/tests/custom.test.ts +40 -0
- package/src/v4/classic/tests/date.test.ts +31 -0
- package/src/v4/classic/tests/datetime.test.ts +296 -0
- package/src/v4/classic/tests/default.test.ts +313 -0
- package/src/v4/classic/tests/description.test.ts +32 -0
- package/src/v4/classic/tests/discriminated-unions.test.ts +592 -0
- package/src/v4/classic/tests/enum.test.ts +285 -0
- package/src/v4/classic/tests/error-utils.test.ts +527 -0
- package/src/v4/classic/tests/error.test.ts +711 -0
- package/src/v4/classic/tests/file.test.ts +91 -0
- package/src/v4/classic/tests/firstparty.test.ts +175 -0
- package/src/v4/classic/tests/function.test.ts +268 -0
- package/src/v4/classic/tests/generics.test.ts +72 -0
- package/src/v4/classic/tests/index.test.ts +829 -0
- package/src/v4/classic/tests/instanceof.test.ts +34 -0
- package/src/v4/classic/tests/intersection.test.ts +171 -0
- package/src/v4/classic/tests/json.test.ts +108 -0
- package/src/v4/classic/tests/lazy.test.ts +227 -0
- package/src/v4/classic/tests/literal.test.ts +92 -0
- package/src/v4/classic/tests/map.test.ts +196 -0
- package/src/v4/classic/tests/nan.test.ts +21 -0
- package/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/src/v4/classic/tests/nonoptional.test.ts +86 -0
- package/src/v4/classic/tests/nullable.test.ts +22 -0
- package/src/v4/classic/tests/number.test.ts +247 -0
- package/src/v4/classic/tests/object.test.ts +553 -0
- package/src/v4/classic/tests/optional.test.ts +103 -0
- package/src/v4/classic/tests/partial.test.ts +147 -0
- package/src/v4/classic/tests/pickomit.test.ts +127 -0
- package/src/v4/classic/tests/pipe.test.ts +81 -0
- package/src/v4/classic/tests/prefault.test.ts +37 -0
- package/src/v4/classic/tests/preprocess.test.ts +298 -0
- package/src/v4/classic/tests/primitive.test.ts +175 -0
- package/src/v4/classic/tests/promise.test.ts +81 -0
- package/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/src/v4/classic/tests/readonly.test.ts +252 -0
- package/src/v4/classic/tests/record.test.ts +332 -0
- package/src/v4/classic/tests/recursive-types.test.ts +325 -0
- package/src/v4/classic/tests/refine.test.ts +423 -0
- package/src/v4/classic/tests/registries.test.ts +195 -0
- package/src/v4/classic/tests/set.test.ts +179 -0
- package/src/v4/classic/tests/standard-schema.test.ts +57 -0
- package/src/v4/classic/tests/string-formats.test.ts +109 -0
- package/src/v4/classic/tests/string.test.ts +881 -0
- package/src/v4/classic/tests/stringbool.test.ts +66 -0
- package/src/v4/classic/tests/template-literal.test.ts +758 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +2182 -0
- package/src/v4/classic/tests/transform.test.ts +250 -0
- package/src/v4/classic/tests/tuple.test.ts +163 -0
- package/src/v4/classic/tests/union.test.ts +94 -0
- package/src/v4/classic/tests/validations.test.ts +283 -0
- package/src/v4/classic/tests/void.test.ts +12 -0
- package/src/v4/core/api.ts +1592 -0
- package/src/v4/core/checks.ts +1285 -0
- package/src/v4/core/config.ts +15 -0
- package/src/v4/core/core.ts +134 -0
- package/src/v4/core/doc.ts +44 -0
- package/src/v4/core/errors.ts +420 -0
- package/src/v4/core/function.ts +176 -0
- package/src/v4/core/index.ts +15 -0
- package/src/v4/core/json-schema.ts +143 -0
- package/src/v4/core/parse.ts +94 -0
- package/src/v4/core/regexes.ts +135 -0
- package/src/v4/core/registries.ts +86 -0
- package/src/v4/core/schemas.ts +3781 -0
- package/src/v4/core/standard-schema.ts +64 -0
- package/src/v4/core/tests/index.test.ts +46 -0
- package/src/v4/core/tests/locales/be.test.ts +124 -0
- package/src/v4/core/tests/locales/en.test.ts +22 -0
- package/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/src/v4/core/to-json-schema.ts +944 -0
- package/src/v4/core/util.ts +775 -0
- package/src/v4/core/versions.ts +5 -0
- package/src/v4/core/zsf.ts +323 -0
- package/src/v4/index.ts +4 -0
- package/src/v4/locales/ar.ts +125 -0
- package/src/v4/locales/az.ts +121 -0
- package/src/v4/locales/be.ts +184 -0
- package/src/v4/locales/ca.ts +127 -0
- package/src/v4/locales/cs.ts +142 -0
- package/src/v4/locales/de.ts +124 -0
- package/src/v4/locales/en.ts +127 -0
- package/src/v4/locales/es.ts +125 -0
- package/src/v4/locales/fa.ts +134 -0
- package/src/v4/locales/fi.ts +131 -0
- package/src/v4/locales/fr-CA.ts +126 -0
- package/src/v4/locales/fr.ts +124 -0
- package/src/v4/locales/he.ts +125 -0
- package/src/v4/locales/hu.ts +126 -0
- package/src/v4/locales/id.ts +125 -0
- package/src/v4/locales/index.ts +38 -0
- package/src/v4/locales/it.ts +125 -0
- package/src/v4/locales/ja.ts +122 -0
- package/src/v4/locales/kh.ts +126 -0
- package/src/v4/locales/ko.ts +131 -0
- package/src/v4/locales/mk.ts +127 -0
- package/src/v4/locales/ms.ts +124 -0
- package/src/v4/locales/nl.ts +126 -0
- package/src/v4/locales/no.ts +124 -0
- package/src/v4/locales/ota.ts +125 -0
- package/src/v4/locales/pl.ts +126 -0
- package/src/v4/locales/ps.ts +133 -0
- package/src/v4/locales/pt.ts +123 -0
- package/src/v4/locales/ru.ts +184 -0
- package/src/v4/locales/sl.ts +126 -0
- package/src/v4/locales/sv.ts +127 -0
- package/src/v4/locales/ta.ts +125 -0
- package/src/v4/locales/th.ts +126 -0
- package/src/v4/locales/tr.ts +121 -0
- package/src/v4/locales/ua.ts +126 -0
- package/src/v4/locales/ur.ts +126 -0
- package/src/v4/locales/vi.ts +125 -0
- package/src/v4/locales/zh-CN.ts +123 -0
- package/src/v4/locales/zh-TW.ts +125 -0
- package/src/v4/mini/checks.ts +32 -0
- package/src/v4/mini/coerce.ts +22 -0
- package/src/v4/mini/external.ts +40 -0
- package/src/v4/mini/index.ts +3 -0
- package/src/v4/mini/iso.ts +62 -0
- package/src/v4/mini/parse.ts +1 -0
- package/src/v4/mini/schemas.ts +1579 -0
- package/src/v4/mini/tests/assignability.test.ts +129 -0
- package/src/v4/mini/tests/brand.test.ts +51 -0
- package/src/v4/mini/tests/checks.test.ts +144 -0
- package/src/v4/mini/tests/computed.test.ts +36 -0
- package/src/v4/mini/tests/error.test.ts +22 -0
- package/src/v4/mini/tests/functions.test.ts +43 -0
- package/src/v4/mini/tests/index.test.ts +871 -0
- package/src/v4/mini/tests/number.test.ts +95 -0
- package/src/v4/mini/tests/object.test.ts +185 -0
- package/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/src/v4/mini/tests/recursive-types.test.ts +275 -0
- package/src/v4/mini/tests/string.test.ts +293 -0
- package/src/v4-mini/index.ts +1 -0
- 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/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;
|