enhancement: improve error messages and add runtime detection for Zod v3/v4 (#1)#674
Closed
Jesssullivan wants to merge 1 commit intociscoheat:mainfrom
Closed
enhancement: improve error messages and add runtime detection for Zod v3/v4 (#1)#674Jesssullivan wants to merge 1 commit intociscoheat:mainfrom
Jesssullivan wants to merge 1 commit intociscoheat:mainfrom
Conversation
adapter mismatch - Enhanced "No shape could be created for schema" error to suggest zod4 adapter - Added console.warn() in zod adapter when Zod v4 schema structure is detected - Added test file for version mismatch detection Closes ciscoheat#594
|
@Jesssullivan is attempting to deploy a commit to the Andreas Sderlund's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
Hello, thank you! Looks very good. No [superforms] prefix is needed, it's obvious what's going on. Happy to merge it and add to the next release! |
Owner
|
Fixed in #678 |
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.
Hi there!
This is my stab at improving the migration flow from zod 3 --> zod 4, I like other users frequently encounter the cryptic error "No shape could be created for schema" when mistakenly using the Zod v3 adapter (
zod) with Zod v4 schemas.This appears to be a common source of confusion (see #594, #630, #649), and I for one usually forget the
zod4revisions needed when upgrading projects to the new structure.Enhancements:
zod4adapterconsole.warn()in thezodadapter when a Zod v4 schema structure is detectedSome questions:
[superforms]prefix desired for warnings, or should a different format be used?zodToJSONSchemafunction for earlier detection?Closes #673
Closes #594
Add Runtime Detection to Zod v3 Adapter
File:
src/lib/adapters/zod.ts:58-70console.warnis allowed by ESLint config[superforms]helps identify sourceTest for Runtime Detection
File:
src/tests/zod-version-detection.test.ts(new file)To test:
Manual Testing
{ zod }(v3 adapter) instead of{ zod4 }