Skip to content
Discussion options

You must be logged in to vote
const a = z.object( {
    a: z.string(),
    b: z.object( {
        a: z.string(),
        b: z.string(),
    } ).partial(),
} )

const payload = {
    a: "1234",
    b: {
        b: "1",
    },
}

console.log( a.safeParse( payload ) )
// {
//   success: true,
//   data: {
//     a: "1234",
//     b: {
//       b: "1",
//     },
//   },
// }

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@JacobWeisenburger
Comment options

Answer selected by JacobWeisenburger
@lukasa1993
Comment options

@JacobWeisenburger
Comment options

@lukasa1993
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5 on November 19, 2023 20:01.