Browse Source

Simple lopp.

pull/235/head
Sebastian Stehle 8 years ago
parent
commit
b724ad67d6
  1. 16
      src/Squidex/Pipeline/ApiExceptionFilterAttribute.cs

16
src/Squidex/Pipeline/ApiExceptionFilterAttribute.cs

@ -68,12 +68,18 @@ namespace Squidex.Pipeline
{
if (!context.ModelState.IsValid)
{
var errors =
context.ModelState.SelectMany(m =>
var errors = new List<ValidationError>();
foreach (var m in context.ModelState)
{
foreach (var e in m.Value.Errors)
{
if (!string.IsNullOrWhiteSpace(e.ErrorMessage))
{
return m.Value.Errors.Where(e => !string.IsNullOrWhiteSpace(e.ErrorMessage))
.Select(e => new ValidationError(e.ErrorMessage, m.Key));
}).ToList();
errors.Add(new ValidationError(e.ErrorMessage, m.Key));
}
}
}
throw new ValidationException("The model is not valid.", errors);
}

Loading…
Cancel
Save