/// <summary> /// Adiciona uma mensagem de valor requerido para o estado da model. /// </summary> /// <param name="controllerContext"></param> /// <param name="modelState"></param> /// <param name="modelStateKey"></param> /// <param name="elementType"></param> /// <param name="value"></param> private static void AddValueRequiredMessageToModelState(System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelStateDictionary modelState, string modelStateKey, Type elementType, object value) { if (((value == null) && !TypeHelpers.TypeAllowsNullValue(elementType)) && modelState.IsValidField(modelStateKey)) { modelState.AddModelError(modelStateKey, GetValueRequiredResource(controllerContext)); } }