Is there a way to get all the error messages for a given form generically? #11698
-
In my example, I have a reusable form that shows a list of error messages and the form can contain 25-30 different inputs with multiple validations so its very tedious to hand-write the path to each possible error message. Is there a way to just map all the error messages and display them in a list something like this: |
Beta Was this translation helpful? Give feedback.
Answered by
Haschikeks
Mar 21, 2024
Replies: 1 comment 3 replies
-
Hey,
<ul>
{Object.values(errors).map((error) => (
<li>{error.message}</li>
))}
</ul> |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Moshyfawn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
error
is a Object. So you could use methods likeObject.values(errors)
to access all of them.