public bool Validate(object sender, object value) { bool isValid = true;//valid until proven invalid if (this.Required == true && value == null) { isValid = false; } if (isValid && this.Min != 0) { var num = value as float?; if (num != null) { if (num < this.Min) { isValid = false; } } } if (isValid && this.Max != 0) { var num = value as float?; if (num != null) { if (num > this.Max) { isValid = false; } } } if (isValid && value != null && !string.IsNullOrEmpty(ValueSet)) { if (!(ValueSet.IndexOf(value.ToString(), System.StringComparison.Ordinal) >= 0)) { isValid = false; } } return(isValid); }