Код: Выделить всё
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-f3b3363d741fe7416fe40aea0ff13c36-d08e5eefbc2ff0ea-00",
"errors": {
"Code": [
"'Code' must not be empty."
],
"Name": [
"'Name' must not be empty."
]
}
}
Код: Выделить всё
public class AddRegionRequestValidator : AbstractValidator
{
public AddRegionRequestValidator()
{
RuleFor(r=>r.Code).NotEmpty().NotNull().WithMessage("{property} is required");
RuleFor(r=>r.Name).NotEmpty().NotNull().WithMessage("{property} is required");
}
}
Код: Выделить всё
public class Response{
public bool IsSuccessful{get;set;}
public dynamic Data{get;set;}
public List ErrorList{get;set;}
public string Message{get;set;}
}
Я хочу получить ответ, как показано ниже.
Код: Выделить всё
{
isSuccessful:false,
data:null,
errorList:[
"'Code' must not be empty.",
"'Name' must not be empty."
],
message:null
}
Подробнее здесь: https://stackoverflow.com/questions/753 ... in-c-sharp