- Notifications
You must be signed in to change notification settings - Fork0
(feat) generate zod schemas from kysely-codegen#96
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Signed-off-by: Benjamin Strasser <bp.strasser@gmail.com>
7fbc960 tof1acd78Comparesjaghori commentedJun 15, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think we can treat the DB as an internal component. We can ensure data integrity through testing. I'll reconsider my decision when we release the project and hit over 1k stars on GitHub. :) |
mledl commentedAug 31, 2024
In general this is not a bad idea. However, the main points of validation should be on the client and when data is passed to our internal API (if there is any). In many cases, the data model for passing data to service layer in order to be persisted differs from the actual DB schema. Therefore, I do not really see the big advantage of this generation. |
This pull request explores the feasibility of using Zod schemas as the foundation for our database type definitions. The primary motivation behind this approach is to leverage the numerous benefits that Zod offers for type validation and type safety. While this PR is very much a draft and not up to our usual code quality standards, it serves as a proof of concept and a starting point for discussion. I was pretty much just interested if it works.
This would allow us to see the values returned from our db to be what they are - potentially unsafe. This is especially true as kysely does not validate what is returned from our database, but very much suggests that the values conform to our types. This was briefly discussed with@jjnp.