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

153
Views
How to get a Detailed Error When using Object schema to validate

I want to create JavaScript function that takes a object and schema and validate and get a detailed errors. In this case im using yup library .

Its possible with using hookform and resolvers in react but I cant figure out how to do without them.

Validation.ts

import * as Yup from "yup";

export const Validation = async (object: any, schema: Yup.ObjectSchema<any>) => {
  try {
    const repsonse = await schema.validate(object, { abortEarly: false });
    console.log(repsonse);
  } catch (e: any) {
    console.log(e);
  }
};

but console.log(e) only output error like :

ValidationError: 5 errors occurred
    at finishTestRun (runTests.js:54:1)
    at runTests.js:8:1
    at finishTestRun (runTests.js:54:1)
    at createValidation.js:60:1

expected output

{
  errors: [
    {
      path: "email",
      message: ["email must be a valid email"],
    },
    .....
  ] 
}
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!