|
@@ -32,10 +32,13 @@ namespace Luticate2.Utils.Middlewares
|
32
|
32
|
var errors = "";
|
33
|
33
|
foreach (var key in context.ModelState.Keys)
|
34
|
34
|
{
|
35
|
|
- var error = " " + key + ": " + context.ModelState[key]
|
36
|
|
- .Errors.Select(modelError => modelError.ErrorMessage)
|
37
|
|
- .Aggregate((s, s1) => s + ", " + s1);
|
38
|
|
- errors += error;
|
|
35
|
+ var state = context.ModelState[key];
|
|
36
|
+ if (state.Errors.Count > 0)
|
|
37
|
+ {
|
|
38
|
+ var error = " " + key + ": " + state.Errors.Select(modelError => modelError.ErrorMessage)
|
|
39
|
+ .Aggregate((s, s1) => s + ", " + s1);
|
|
40
|
+ errors += error;
|
|
41
|
+ }
|
39
|
42
|
}
|
40
|
43
|
throw new LuResultException(LuResult<object>.Error(LuStatus.InputError, "Validation error:" + errors, ""));
|
41
|
44
|
}
|