I'm working on a simple file upload form using react-hook-form and I need to validate that a file has been selected for upload. Using yup for validation. I realize there are other questions on this topic but I was unable to find a working solution.
My file upload component is based (almost 100% the same) on this answer https://mcmap.net/q/981544/-how-to-use-react-dropzone-with-react-hook-form. It seems to be working just fine, if I disable validation the file is uploaded correctly.
The issue I'm facing is when validating whether a file has been selected
I get the error file must be a 'object' type, but the final value was: 'null'
.
Here's a CodeSandbox showing the problem. I added some prints showing the contents of the "file" form property and its type (which shows as object)
file: yup.mixed()
otherwise mixed() is undefined.. – Juliannajulianne