write an enum-keyed map as z.partialRecord, which accepts the subsets serde writes - #237
Merged
Merged
Conversation
… serde writes `z.record` over an enumerated key schema demands every member be present, so a partially populated `HashMap<EnumKey, V>` — and an empty one — was rejected by its own generated schema. Measured against real serde payloads: a partial map failed with one missing-key issue per absent member per field, an empty map with all of them, while the full map alone parsed. TypeScript had said `Partial<Record<...>>` all along, and the JSON document carries no `required`, so Zod was the one surface rejecting what the type system and the document both admit — and what a Rust `HashMap` plainly holds. The record call is chosen off a new wire answer for an enumerated key, recorded where a plain enum registers and forwarded by the existing brand and alias forwarding — the constructor's question being whether the key's published Zod binding enumerates, which a brand over an enum does even though its JSON stays an open object. A registry miss answers as enumerated, which is what a key naming an enum declared later reads: measured safe, since `partialRecord` is runtime-identical to `record` over every non-enumerating key schema this crate emits, and a forward-declared key that is not an enum is already refused elsewhere. TypeScript and the JSON document do not move. A stray key is still refused. Verified on the verbatim emission with real payloads: partial, full and empty all parse byte-identically, ajv agreeing before and after — the before-state verdicts are recorded in the pinning test, showing Zod alone was wrong. just fmt, just check, just quick, just lint-all across all 68 toggles, and the test powerset across all 68 in four partitions — all green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
z.recordover an enumerated key schema demands every member be present, so apartially populated
HashMap<EnumKey, V>— and an empty one — was rejected byits own generated schema. Measured against real serde payloads: a partial map
failed with one missing-key issue per absent member per field, an empty map
with all of them, while the full map alone parsed. TypeScript had said
Partial<Record<...>>all along, and the JSON document carries norequired,so Zod was the one surface rejecting what the type system and the document both
admit — and what a Rust
HashMapplainly holds.The record call is chosen off a new wire answer for an enumerated key, recorded
where a plain enum registers and forwarded by the existing brand and alias
forwarding — the constructor's question being whether the key's published Zod
binding enumerates, which a brand over an enum does even though its JSON stays
an open object. A registry miss answers as enumerated, which is what a key
naming an enum declared later reads: measured safe, since
partialRecordisruntime-identical to
recordover every non-enumerating key schema this crateemits, and a forward-declared key that is not an enum is already refused
elsewhere.
TypeScript and the JSON document do not move. A stray key is still refused.
Verified on the verbatim emission with real payloads: partial, full and empty
all parse byte-identically, ajv agreeing before and after — the before-state
verdicts are recorded in the pinning test, showing Zod alone was wrong.
just fmt, just check, just quick, just lint-all across all 68 toggles, and the
test powerset across all 68 in four partitions — all green.