protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (validationContext.Items.Count > 0) { var Model = validationContext.Items["Model"]; if (ValidateTypeHander.IsValidate(Groups, Model)) { string tips = string.Empty; if (Minimum.GetType() == typeof(int)) { var v = Convert.ToInt32(value); var min = Convert.ToInt32(Minimum); var max = Convert.ToInt32(Maximum); if (v < min || v > max) { if (!string.IsNullOrEmpty(ErrorMessage)) { Message = ErrorMessage; } if (!string.IsNullOrEmpty(Message)) { tips = Message; } else if (!string.IsNullOrEmpty(MessageKey)) { tips = XMLConfiguartionService.GetXmlConfig(MessageKey); } return(new ValidationResult(tips)); } } else if (Minimum.GetType() == typeof(double)) { var v = Convert.ToDouble(value); var min = Convert.ToDouble(Minimum); var max = Convert.ToDouble(Maximum); if (v < min || v > max) { if (!string.IsNullOrEmpty(ErrorMessage)) { Message = ErrorMessage; } if (!string.IsNullOrEmpty(Message)) { tips = Message; } else if (!string.IsNullOrEmpty(MessageKey)) { tips = XMLConfiguartionService.GetXmlConfig(MessageKey); } return(new ValidationResult(tips)); } } } } return(ValidationResult.Success); }