Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Cómo realizar dos pruebas en el mismo campo sí donde una prueba usa async await

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; } ), });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!