La validación funciona para requerido e imageHeight pero no para fileFormat. Estoy usando async await para esperar hasta que se cargue la imagen y devolver la altura exacta.
Matriz de formatos admitidos
const SUPPORTED_FORMATS = [ "image/jpg", "image/jpeg", "image/png", ];Función para obtener la altura de la imagen.
const getImageHeight = (value) => { return new Promise((resolve, reject) => { let img = new Image(); img.onload = () => resolve(img.height); img.onerror = reject; img.src = value?.data || value; }); };Sí validación
export const ImageValidate = Yup.object({ image: Yup.mixed() .required("Please select image") .test("fileFormat", "Unsupported Format", (value) => { return SUPPORTED_FORMATS.some((type) => type === value?.file?.type ); }) .test( "imageHeight", "image height should be >=100", async (value) => { if (value) { const dimension = await getImageHeight(value); if (dimension.height >=100) { return true; } return false; } return false; } ), });