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

232
Visualizações
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 à 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