Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ModelStateExtensions.ToSerializableDictionary does not handle duplicate keys #15

benfoster opened this Issue Mar 3, 2013 · 0 comments


None yet
1 participant

benfoster commented Mar 3, 2013

Update with the following:

    public static IDictionary<string, string[]> ToSerializableDictionary(this ModelStateDictionary modelState)
        return modelState.Where(x => x.Value.Errors.Any()).ToDictionary(
            kvp => kvp.Key,
            kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()

@benfoster benfoster closed this in 51d5232 Mar 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment