Skip to content

[question] ZodType with ZodObject props #1886

Answered by domosedov
domosedov asked this question in Q&A
Discussion options

You must be logged in to vote

Modern solution TS 4.9+

type User = {
    id: number
    name: string
    age: number
}

const UserSchema = z.object({
    id: z.number(),
    name: z.string(),
    age: z.number()
}) satisfies z.ZodType<User>

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@victorvat
Comment options

Answer selected by JacobWeisenburger
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants
Converted from issue

This discussion was converted from issue #1495 on January 14, 2023 18:05.