Created
January 30, 2019 13:16
-
-
Save evgomes/6f747c5f675e86e2f4209163005107bd to your computer and use it in GitHub Desktop.
ModelStateExtensions from Supermarket API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.AspNetCore.Mvc.ModelBinding; | |
namespace Supermarket.API.Extensions | |
{ | |
public static class ModelStateExtensions | |
{ | |
public static List<string> GetErrorMessages(this ModelStateDictionary dictionary) | |
{ | |
return dictionary.SelectMany(m => m.Value.Errors) | |
.Select(m => m.ErrorMessage) | |
.ToList(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment