fix: remove validation on reads, matching documented behavior#16
Merged
fix: remove validation on reads, matching documented behavior#16
Conversation
The README states "Zod validation happens on writes, never on reads" but validation was running during normalize() via buildEntityMap(). This caused ValidationError when reading data written with an older schema version, breaking the forward-only migration pattern. Changes: - Remove validateWithStandardSchema call in buildEntityMap - Update tests to use z.date()/z.boolean()/z.number() instead of z.coerce.* - Zen's decodeData handles DB→JS type conversion (dates, booleans, JSON) - Zod coerce/transform only runs on writes, not reads Fixes #14 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
validateWithStandardSchemacall during reads inbuildEntityMapz.date()/z.boolean()/z.number()instead ofz.coerce.*decodeDatahandles DB→JS type conversion (dates, booleans, JSON)Background
The README states "Zod validation happens on writes, never on reads" but validation was running during
normalize()viabuildEntityMap(). This causedValidationErrorwhen reading data written with an older schema version.Data flow:
Zen's
decodeDatahandles all DB→JS conversions:Users should use
z.date()notz.coerce.date()— Zen handles the conversion.Test plan
Fixes #14
🤖 Generated with Claude Code