Fastest Way to Auto Generate Types for Typescript and Input validation
source link: https://dev.to/seyyedkhandon/fastest-way-to-auto-generate-types-for-typescript-and-input-validation-478p
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
14 1
Fastest Way to Auto Generate Types for Typescript and Input validation
Short description
Writing types for API's especially giant JSON's are frustrating especially when it comes to input validation.
solution:
Just paste your json inside app.quicktype.io or it's vscode
Now you can paste that type into transform.tools/typescript-to-zod to generate the corresponding zod schema for input validation:
Note 🏅 For Practical step by step example check this 4min youtube video:
Top comments (5)
A schema from backend can speed up generating types
Yeah, but Most of the time schema for 3rd party api's are not available.
CollapseExpandCollapseExpand
And what about nullable types? That's why I prefer to stick to the server-side scheme
It supports that too. bu what do you mean about server side scheme? can you please explain more
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK