Multiple Error messages #1871
Answered
by
kotarella1110
joshyboyrules
asked this question in
Q&A
-
Hello! First off, thanks for this lib, really excited to use it in our product soon. Currently, we have a use case where we would like to display multiple validation errors at the same time. Is this possible with react hook form? AFAIK, the validation stops once an error is found so other validation errors are not populated. validate: {
required: () => {}, // e.g. required message will be populated by not minLength.
minLength: () => {}
} Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
kotarella1110
Jun 15, 2020
Replies: 1 comment 5 replies
-
@joshyudeep you can set validateCriteriaMode to // set validateCriteriaMode to `all`
const { register } = useForm({
validateCriteriaMode: "firstErrorDetected",
})
{errors.yourInputName?.types && Object.entries(errors.yourInputName?.types).map(([type, message]) => (
<p key={type}>{message}</p>
))} please see example here. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
bluebill1049
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@joshyudeep you can set validateCriteriaMode to
all
for multiple error messages.please see example here.