Is it possible to return a custom error response from class-validator inside of NestJs.
NestJS currently returns an error message like this:
{
"statusCode": 400,
"error": "Bad Request",
"message": [
{
"target": {},
"property": "username",
"children": [],
"constraints": {
"maxLength": "username must be shorter than or equal to 20 characters",
"minLength": "username must be longer than or equal to 4 characters",
"isString": "username must be a string"
}
},
]
}
However the service that consumes my API needs something more akin to:
{
"status": 400,
"message": "Bad Request",
"success": false,
"meta": {
"details": {
"maxLength": "username must be shorter than or equal to 20 characters",
"minLength": "username must be longer than or equal to 4 characters",
"isString": "username must be a string"
}
}
}