Open lossen opened 5 years ago
Is this a Formik or a yup question?
Is this a Formik or a yup question?
Probably you're right. My bad, sorry.
I think this problem is related to Formik. Because Formik needs to identify the type of input to pass the correct value to the validators. If the input type is a file, Formik must pass event.target.files
to the validator. Otherwise, validators will always receive the file name and any validation would be very superficial.
YUP file upload not woking this example. when i click file upload button , it's throw error file is too large before uloading images. please anyone give solution
const schema = yup.object().shape({ bankname: yup.string().required(), bankcode: yup.string().required(), servicecode: yup.string().required(), signincertificatealias: yup.string().required(), intermediatecertificatealias: yup.string().required(), rootcertificatealias: yup.string().required(), privatekeyalias: yup.string().required(), hsmindexvalue: yup.string().required(), regbanklogo: yup .mixed() .required('You need to provide a file') .test('fileSize', 'The file is too large', (value) => { return value && value.size <= 1000000; }) .test('type', 'We only support jpeg', (value) => { return value && value.type === 'image/jpeg'; }) })
🐛 Bug report
I am using formik and yup for validation this is my yup object It is working, but I have noticed that this code doesn't support some formats
Current Behavior
My supported formats : [ "image/jpg", "image/jpeg", "image/png", "audio/mp3", "video/mp4", "video/mov", ] But when I select this formats : .cmx, .sketch, .cdr validation doesn't work
Expected behavior
All format which doesn't include in my supported formats array should be rejected by the validation
Reproducible example
I have partially used code from this example https://codesandbox.io/s/formik-file-input-with-validation-pn3vb
Your environment