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

113
Views
Custom validation using Joi in Javascript

I'm using Joi to validate some data from user.

I want to compare between two keys (type: array) in the payload and validate that one should be the subset of the other.

for example:

{
    "colors":["green", "blue"],
    "animals":["cat"],
    "branches":[{
       "colors":["green", "red"]
    }]
}

In above example i want to make sure that first array (colors) is superset of second array inside key branches (colors).

this could be achive by following code in js, but i want to do it using Joi.

const result1 = req.body.branches.colors.every(val => req.body.colors.includes(val));

Any help?

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!