Skip to content

How to retrieve validated values from createServerValidate in Next.js? #778

Discussion options

You must be logged in to vote

Let's tackle these one-by-one :)

Handle Validated Data Post Validate

However, how do you retrieve the validated data after the validation has succeeded?

You don't! At least not from our API. You parse formData again manually using your tool of choice. I would suggest using the same as we do internally (decode-formdata), but you can use any tool you'd like.

Add More Errors

And how should you return an error outside of the serverValidate call so that it shows on the client?

You would add the form error to the onServerValidate behavior ideally. You want your non-form validation to occur outside of the serverValidate function call. If you wanted to pass state to the client beyond the serv…

Replies: 3 comments 2 replies

Comment options

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

Answer selected by crutchcorn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@CarelessInternet
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
4 participants