我在 NestJS 中使用类验证器来创建这样的验证:
export class LoginDTO {
@IsEmail()
@MinLength(4)
email: string;
@IsNotEmpty()
@MinLength(4)
password: string;
}
它有效,但不如预期。返回的对象如下所示:
{
"statusCode": 400,
"message": [
"email must be longer than or equal to 4 characters",
"email must be an email"
],
"error": "Bad Request"
}
虽然我希望它包含这样的所有信息:
{
"statusCode": 400,
[{
target: /* post object */,
property: "title",
value: "Hello",
constraints: {
length: "$property must be longer than or equal to 10 characters"
}]
"error": "Bad Request"
}
如何返回所有丢失的属性?