Skip to content

Commit 11c9268

Browse files
authored
revert(core): drop the exactOptional parse prototype from #6432 (#6438)
The hunk is labelled OPTION B PROTOTYPE and changes what an exact optional accepts. Every inner that accepts undefined on its own -- coerce, any, unknown, undefined, literal(undefined), catch -- was rejected, and specific type errors were replaced with nonoptional. z.exactOptional(z.undefined()) could never match a present key. The propValues half of #6432 and its tests are untouched.
1 parent a38ab4a commit 11c9268

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

‎packages/zod/src/v4/core/schemas.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,13 +3743,8 @@ export const $ZodExactOptional: core.$constructor<$ZodExactOptional> = /*@__PURE
37433743
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
37443744
util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
37453745

3746-
// OPTION B PROTOTYPE: fix in $ZodExactOptional.parse, expressed through the inner's optin rung.
3746+
// Override parse to just delegate (no undefined handling)
37473747
inst._zod.parse = (payload, ctx) => {
3748-
const _inner = def.innerType._zod;
3749-
if (payload.value === undefined && _inner.optin !== "defaulted" && _inner.optout !== "optional") {
3750-
payload.issues.push({ code: "invalid_type", expected: "nonoptional", input: undefined, inst });
3751-
return payload;
3752-
}
37533748
return def.innerType._zod.run(payload, ctx);
37543749
};
37553750
}

0 commit comments

Comments
 (0)