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

432
Views
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
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!