protected override ValidationResult IsValid(object value, ValidationContext validationContext) { // Get values var comparableValue = value as IComparable; IComparable comparableOtherValue; try { comparableOtherValue = validationContext.GetPropertyValue<IComparable>(this.OtherPropertyName); } catch (ArgumentException aex) { throw new InvalidOperationException("Other property not found", aex); } // Empty or noncomparable values are valid - let others validate that if (comparableValue == null || comparableOtherValue == null) return ValidationResult.Success; var compareResult = comparableValue.CompareTo(comparableOtherValue); if (compareResult == 1 || (this.AllowEqual && compareResult == 0)) { // This property is greater than other property or equal when permitted return ValidationResult.Success; } else { // This property is smaller or equal to the other property if (string.IsNullOrWhiteSpace(this.OtherPropertyDisplayName)) { this.OtherPropertyDisplayName = validationContext.GetPropertyDisplayName(this.OtherPropertyName); } return new ValidationResult(this.FormatErrorMessage(validationContext.DisplayName)); } }