Replies: 2 comments 8 replies
|
could you share your pakcage.json for the lib version? |
|
The root cause is from line 19 of index.js, the method "test()" is using "value[0]" but at initial time, "value" is undefined therefore the validation will fail as an unexpected error. While yup resolver from @hookform/resolvers is using "try catch" to wrap the execution of all validation rules, the unexpected error is catch but its error object from "catch" statement is not a validation error object (which is object with array data) and failed again with reduce method. Just correcting the custom validation at line 19 will fix the error. Working sample: https://codesandbox.io/s/react-hook-form-reset-v7-forked-i5ht5?file=/src/index.js What do you think about a double check when try catch error for resolver ? We just need to check if the error is expected validation error or not, if not, we re-throw new error with more clear context for the unexpected one. |








@Ekeu
The root cause is from line 19 of index.js, the method "test()" is using "value[0]" but at initial time, "value" is undefined therefore the validation will fail as an unexpected error.
While yup resolver from @hookform/resolvers is using "try catch" to wrap the execution of all validation rules, the unexpected error is catch but its error object from "catch" statement is not a validation error object (which is object with array data) and failed again with reduce method.
Just correcting the custom validation at line 19 will fix the error.
Working sample: https://codesandbox.io/s/react-hook-form-reset-v7-forked-i5ht5?file=/src/index.js
@bluebill1049 @jorisre
What do you think about a …