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

158
Views
Can I use the data given to Joi.validate() function instead of the result.value that it returns

The documented way:

 const data = {...someDataHere}


 const { error, value } = joi.validate(data, schema);

 if (error) return console.log(error);

    
...do stuff using `value` here

Using try/catch:

const data = {...someDataHere}

try {
  const { error, value } = joi.validate(data, schema);

  if (error) throw new Error(error)
} catch (error) {
  console.log(error);
}

...do stuff using `data` here since we can not access `value`

Question:

In regards to Joi validation library

Since I can't access value here because it's in a try/catch block, can I use data instead? Is it the exact same data all the time? And is safe/okay?

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!