A related tool for Zod schemas #1
Replies: 2 comments 1 reply
-
That's really cool! I'm a big fan of Zod (somewhat long-time sponsor too :)). I've thought about having a more data-intermediate approach to generation which would be possible to be used to output in different formats and perform resolving of imports too. Right now it outputs code as it goes through the AST without an intermediate representation. So for a statement like /* some godoc */
type Foo = map[string]bar.Dep // line comment It would generate some sort of intermediate representation TypeDecl {
Doc: "some godoc",
Name: "Foo"
Type: MapDecl {
....
}
Comment: "line comment"
} From that data it would then be somewhat easy to serialize into other structures like Zod, as well as to be a building block for more complex usecases like generating an API client entirely (you would put some sort of directives into comments, like Thinking about it a bit more: I'm not sure what you are using Zod for in this case? I've used it on the backend to validate user inputs, but with a Golang backend I'm not sure where it fits (unless the user is directly inputting JSON into a textfield). |
Beta Was this translation helpful? Give feedback.
-
I was Googling a bit, you could chain this in the pipeline https://www.npmjs.com/package/ts-to-zod as the comments are persisted |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! A friend shared this in my community and it looks useful as I usually use Go and TypeScript together!
Figured it was a good place to plug my own related tool which is specifically for Zod schemas in TS: https://github.com/Southclaws/supervillain/
Beta Was this translation helpful? Give feedback.
All reactions