We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given:
import { z } from 'zod' import { zodToTs } from 'zod-to-ts' // define your Zod schema const UserSchema = z.object({ username: z.string().describe("User's name"), age: z.number().describe("User's age"), inventory: z.object({ name: z.string().describe("Item name"), itemId: z.number().describe("Item ID number"), }).array(), }) // pass schema and name of type/identifier const { node } = zodToTs(UserSchema, 'User') const nodeString = printNode(node, { descriptions: true })
Result:
"{ username: string // User's name age: number // User's age inventory: { name: string // Item name itemId: number // Item ID number }[] }"
Obviously in this case the descriptions are purely redundant but for the use cases I have in mind the comments could add real value.
The text was updated successfully, but these errors were encountered:
Not sure if this package is updated. But I needed something today that had coerce, nullable, defaults, date and inline comments. So here it is, if someone can make it a module. https://gist.github.com/kevbook/861e0885296827bf15530e3a921e1246
coerce
nullable
defaults
date
comments
Sorry, something went wrong.
No branches or pull requests
Given:
Result:
Obviously in this case the descriptions are purely redundant but for the use cases I have in mind the comments could add real value.
The text was updated successfully, but these errors were encountered: