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

195
Visualizações
joi validation each items of array object must have same value

i have form request like this

{
    "data": [
        {
            "transaction": "LNS",
            "product": "XXX",
            "lot": "1",
            "liquidPrice": "0",
            "liquidId": 0,
            "limitPrice": "1780.00",
            "stopPrice": "0"
        },
        {
            "transaction": "LNS",
            "product": "XXX",
            "lot": "1",
            "liquidPrice": "0",
            "liquidId": 0,
            "limitPrice": "1780.00",
            "stopPrice": "0"
        }
    ]
}

i want to check if the array data bigger than one object, the value of key object product must same as another array of object

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can follow these steps for check of key object

  1. Compare each and every element of two arrays.
  2. Return the matched element.
  3. Add the element or object into the object of array.

Check this example :

let Joi = require('joi')
let service = Joi.object().keys({
  serviceName: Joi.string().required(),
})

let services = Joi.array().items(service)

let test = Joi.validate(
  [{ serviceName: 'service1' }, { serviceName: 'service2' }],
  services,
)
about 4 years ago · Juan Pablo Isaza Relatório

0

you using Joi validation libary:

Joi.array().items({
     "transaction": Joi.string().required(),
      ...
}).min(1)
about 4 years ago · Juan Pablo Isaza Relatório
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