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

427
Vistas
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 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