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

318
Views
How to get multiple exceptions with NESTJS?

I would like to know if there are any examples of how to format the returns this way.

{
  "errors": {
    "due_date": [
      "não pode ficar em branco",
      "não pode estar mais que três anos a frente",
      "não pode estar no passado"
    ]
  }
}

I currently handle my exceptions this way

if (!contract.title) {
    throw new BadRequestException('Title is a required field');
}
if (contract.phase in Phase === false) {
     throw new BadRequestException(
       'Contract phase informed is invalid or non-existent',
    );
}

Grateful...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use class-transformer package and add a global ValidationPipe in the main.ts file to validate all the request with a body which has corresponding dto's

Ref: How to add Validation to request body in NestJS

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!