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

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