Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda