Description
Problem
In Zod v3, the English locale provided a user-friendly "Required" message when input
is undefined
:
v3 behavior:
zod/packages/zod/src/v3/locales/en.ts
Lines 7 to 13 in 1b0a5e5
However, in v4, this special handling was removed
zod/packages/zod/src/v4/locales/en.ts
Lines 75 to 76 in 1b0a5e5
and resulting in verbose error messages like:
"Invalid input: expected string, received undefined"
Related discussion (Q&A): #4490
Solution
Restore the v3 behavior in v4 locales for better UX:
English:
if (issue.input === undefined) return "Invalid input: Required";
Japanese:
if (issue.input === undefined) return "無効な入力: 必須項目です";
Breaking Change Notice
This change will update error messages from:
"expected {type}, received undefined"
to:
"Required"
Question: Is it okay to update existing test cases that expect the old verbose format?
I have a working implementation ready in my fork: https://github.com/tobigumo/zod/tree/feat/v4-restore-required-error-message
Ready to submit PR once this approach is approved.