-
-
Notifications
You must be signed in to change notification settings - Fork 247
Develop Zod to Valibot codemod #1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
EltonLobo07
wants to merge
108
commits into
main
Choose a base branch
from
zod-to-valibot-codemod
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
unify the transformation of all components of a Zod schema, specifically transform Zod properties the same way other components of a Zod schema are transformed.
add zod `record` transform
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.
Motivation
Just a few days before Valibot v1 was about to be released, @fabian-hiller created a poll on X. The results were pretty clear - The community needs a Zod to Valibot codemod! We also think the codemod will help Valibot and the projects that wish to migrate from Zod to Valibot. That's why we have decided to develop an official Zod to Valibot codemod.
How do we plan to develop the codemod?
In most cases, Zod to Valibot code transformation is very easy since both APIs have a lot of similarities. We recommend reading this guide for more details. However, we also discovered some cases were tricky or impossible to transform. That's why we think this would be the best strategy to develop the codemod:
Over the last month, we have identified most of the cases. You can find the tests associated with all of the identified cases here. Step number 2 is where we will need community's help.
Goal
The main purpose of this draft PR is to get some amount of help from interested contributors to develop the codemod.
Project structure
Everything related to the codemod is inside
/codemod/zod-to-valibot
on thezod-to-valibot-codemod
branch. The__testfixtures__
folder contains tests for each identified case. Thetest-setup.test.ts
file inside thesrc
folder is where the names of the tests that are completed (the Zod to Valibot transformation works) are placed. Thetransform
folder inside thesrc
folder contains all of the logic related to the codemod.How to contribute
Before you get started, we recommend reading the contributing doc.
Most of the time, these are the steps you will follow:
zod-to-valibot-codemod
branch!Some important points to keep in mind:
/src/transform
folder are not fixed. Feel free to use your own judgment while adding new files or code.If you have any questions, feel free to reach out to us on Discord. There is a section dedicated to the codemod!
Progress table