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

194
Views
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 answers
Answer question

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 Report

0

you using Joi validation libary:

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