protected override ValidationResult IsValid(object value, ValidationContext ctx)
{
// get the otherProperty value.
var otherPropertyValue = ctx.ObjectInstance.GetType().GetProperty(otherProperty).GetValue(ctx.ObjectInstance, null);
ValidationResult result;
// check for not null values, and then compare the properties. The (int) cast is required by
// Microsoft enum logic.
if (value!= null && otherPropertyValue != null && ((IComparable)value).CompareTo((IComparable)otherPropertyValue) == (int)this.op)
{
result = ValidationResult.Success;
}else{
// call ErrorMessage generator
result = new ValidationResult(GetErrorMessage(ctx.DisplayName));
}
return result;
}