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

428
Visualizações
yup validation af array of array of object now working

I have this weird construction where I have an array of many arrays with a single object of some certain shape inside, and I am not able to validate it, it allows for the empty first array no matter what, please have a look a this construct and tell me what I am doing wrong

yup.array().of(
        yup
            .array()
            .length(1)
            .of(
                yup.object().shape({
                    from: yup.string(),
                    to: yup.string(),
                    duration: yup.object().shape({
                        h: yup.number().nullable(),
                        m: yup.number().nullable()
                    }),
                    dates: yup.array().of(yup.string()),
                    weekDaysWithTime: yup.array().of(
                        yup.object().shape({
                            day: yup.string(),
                            time: yup.object().shape({
                                h: yup.number().nullable(),
                                m: yup.number().nullable()
                            })
                        })
                    )
                })
            )
    )

the shape I need to validate is basically

[
[{}],[{}],[{}]
]

and it allows for just one outer empty array [] to be validated.

Many thanks

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