Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Form error summary using Formik with yup validationSchema

I want to show a summary of all errors found by yup validationSchema.

My CodeSandbox example: https://codesandbox.io/s/7m3n44po80

This is how it should look like

How it should look like if there are errors on submit. In the screenshot the error summary is hardcoded just as in my CodeSandbox: Error Summary

I couldn't find any "hook" where I can grab all the validation errors.

like image 959
CodingYourLife Avatar asked Jan 02 '23 00:01

CodingYourLife


1 Answers

You've got an errors prop passed to your component when using withFormik

For example: https://codesandbox.io/s/j216zmo0xw

like image 62
CD.. Avatar answered Jan 08 '23 02:01

CD..