Repository navigation
docs(v4): document coerce missing-key breaking change - #5964
Conversation
|
TL;DR — Documents a v4 breaking change where Key changes
Summary | 1 file | 1 commit | base:
The v4 object parser checks required keys before delegating to field validators, so
|
There was a problem hiding this comment.
Important
Good direction — this is genuinely missing from the migration guide. Two small tweaks before merging: the prose leans on implementation detail (and is actually inverted — the field schema does run; the object parser then discards the result and emits a nonoptional issue), and the quoted error string is missing the Invalid input: prefix that users actually see. The issue reporter on #5957 already flagged the "object parser / delegating" framing as more confusing than just describing the behavior. Matching the register of the neighboring entries (observable behavior + // Zod 3: / // Zod 4: delta) should close the gap.
Claude Opus | 𝕏
9db03f2 to
237092e
Compare
There was a problem hiding this comment.
No new issues. Reviewed the following changes:
- Trimmed the prose to a single observable-behavior sentence, dropping the implementation-detail framing.
- Updated the Zod 4 code comment to quote the real error string (
Invalid input: expected nonoptional, received undefined).
Prior review feedback:
- Trim internals-leaning prose to observable behavior — addressed
- Quote the actual emitted error message verbatim — addressed
Claude Opus | 𝕏

Refs #5957.
The v4 object parser checks required keys before delegating to field validators, so a
z.coerce.*field on an object schema now rejects a missing key withexpected: \"nonoptional\"instead of coercing `undefined`. This is intentional (and the only coherent choice across all coercers —String(undefined)→\"undefined\",Number(undefined)→NaN), but it wasn't called out in the migration guide. Adds a short note next to the existingz.coercesection pointing users to.default().Test plan