Skip to content

When performing validation is it possible to preserve the errors array? #860

Answered by my-slab
TomppaPackage asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think so, because a validation can only return a ValidationError which is a string. However, you can access the issues array and transform the error message to your liking using the transformErrors function that is passed to the adapter.

e.g., just show one of the error messages.

 validatorAdapter: zodValidator({
    transformErrors: (e) => {
      return e?.[0]?.message
    },
  }),

Replies: 1 comment 1 reply

Comment options

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

Answer selected by TomppaPackage
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