/// <summary> /// Determines whether [is group valid] [the specified model state]. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="modelState">State of the model.</param> /// <param name="model">The model.</param> /// <param name="groupName">Name of the group.</param> /// <returns> /// <c>true</c> if [is group valid] [the specified model state]; otherwise, <c>false</c>. /// </returns> public static bool IsGroupValid <T>(this ModelStateDictionary modelState, T model, string groupName) { if (modelState == null) { throw new ArgumentNullException("modelState"); } if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrEmpty(groupName)) { return(modelState.IsValid); } return(modelState.IsGroupValid(model, groupName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()))); }