22 lines
562 B
C#
22 lines
562 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
|
namespace LCU.API.Collections.RepoApi.Extensions
|
|
{
|
|
public static class ModelStateMessages
|
|
{
|
|
public static List<string> GetErrorMessages(this ModelStateDictionary dictionary)
|
|
{
|
|
if (dictionary == null)
|
|
{
|
|
return new List<string>();
|
|
}
|
|
|
|
return dictionary.SelectMany(m => m.Value.Errors)
|
|
.Select(m => m.ErrorMessage)
|
|
.ToList();
|
|
}
|
|
}
|
|
}
|