I'm using Yup with Formik and i run into problem, where I need to validate my file-upload. Validation works, but I'm facing problem, because I can't submit form without file. I need to make it notRequired and because initialValue is undefined it test that undefined value.
My code:
attachment: Yup.mixed()
.nullable()
.notRequired()
.test("FILE_SIZE", "Uploaded file is too big.", value => value && value.size <= FILE_SIZE)
.test("FILE_FORMAT", "Uploaded file has unsupported format.", value => value && SUPPORTED_FORMATS.includes(value.type))