Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
yup .test validation prevent other rules from execution in the schema

I have a custom test, but when its implemented inside a schema, it stops the whole schema, even I already have abortEarly: true for the schema itself.

I defined the test like this:

const dateFormatRequired = () => yup
                .string()
                .test({
                    name: 'date-format-bd',
                    message:'Date format should be MM/DD/YYY',
                    test: (value, cotext) => {
                        console.log(value)
                        const dateInList = value.split('-');
                        const yearHasCorrectDigit = dateInList[0].length === 4;
                        const monthAndDayHasCorrectDigit = dateInList[1].length == 2 && dateInList[2].length == 2;
                        return yearHasCorrectDigit && monthAndDayHasCorrectDigit;
                    },
                    params: {
                        abortEarly: false
                    }
                })

Schema itself like this:

const schema = yup.object().shape({
                dateOfBirth: dateFormatRequired(),
                gender: isRequiredOnly,
            );
schema
   .validateSync({...some values match my data shape}, { abortEarly: false })

When the dateFormatRequired failed, the whole schema's error.inner will be empty.

Any suggestions how can I debug this further or a solution?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda