复杂属性的FluentValidation错误分组

时间:2018-01-16 07:06:24

标签: c# fluentvalidation

我有一个问题,想弄清楚如何覆盖'flat'错误格式,如下所示:

apply

成像:

{
    "Discount": [
        "'Discount' must be greater than or equal to '0'."
    ],
    "Guest.LastName": [
        "'Last Name' should not be empty."
    ],
    "Guest.CountryId": [
        "'Country Id' should not be empty."
    ],
    "Guest.FirstName": [
        "'First Name' should not be empty."
    ],
    "Guest.DocumentTypeId": [
        "'Document Type Id' should not be empty."
    ]
}

我没有做任何花哨的事情,只是打电话:

{
    "Discount": [
        "'Discount' must be greater than or equal to '0'."
    ],
    "Guest": [
        //grouped errors
    ]
}

甚至可以将结果错误作为非平面列表获取吗?

谢谢 彼得

0 个答案:

没有答案