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...
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