Skip to content

superRefine don't work #3296

Answered by JacobWeisenburger
f1eeman asked this question in Q&A
Discussion options

You must be logged in to vote

Here is a much simpler example:

const schema = z.object( {
    foo: z.string()
} ).superRefine( ( values, ctx ) => {
    console.log( 'superRefine', values )
    // never gets called
} )

const result = schema.safeParse( {} )
!result.success && console.log( result.error.issues )
// [
//     {
//         code: "invalid_type",
//         expected: "string",
//         received: "undefined",
//         path: [ "foo" ],
//         message: "Required",
//     }
// ]

Not sure if this is a bug or intended behavior

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
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
2 participants
Converted from issue

This discussion was converted from issue #3290 on March 04, 2024 12:52.