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

224
Views
How to add array inside an array in Joi validator for mongoose schema?

I'm getting this error while compiling the code node index.

Invalid schema configuration: `undefined` is not a valid type within the array `location`.

When I add this to the Joi validation schema, I get the error.

joi.array().items(joi.array().items(joi.number().integer())).default([]),

The array that I want to validate,

{
  // other fields..
  location: [[1,32,145], [0,1,null]],
  // other field 
}

I have tried other iterations to figure out what causes the error.

joi.array().items().default([]) // No error
joi.array().items(joi.number().integer()) // No error
joi.array().items(joi.array().items()) // This caused error 

I think adding an array inside an array is causing the error.

IMP NOTE: Using schema like this, and error around this.

new mongoose.Schema(joigoose.convert(PSS), { _id: false, versionKey: false })

I have manually added the array inside an array in MongoDB Document, which means this error is with mongoose, as joi allows array inside an array.

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!