public bool Validate(IValidatable sender, string fieldName, object value) { IFieldValidator constraint = Constraints[fieldName]; if (constraint == null) { return(true); } //nothing to validate, pass string message; if (constraint.Level == ErrorLevel.Error) { message = constraint.ErrorMessage; } else if (constraint.Level == ErrorLevel.Warning) { message = "Warning::" + constraint.ErrorMessage; } else { message = String.Empty; } if (constraint.Validate(sender, value) == false)//fail validation { sender.AddError(fieldName, message); return(false); } else //passes validation { sender.RemoveError(fieldName, message); return(true); } }
public bool Validate(IValidatable sender, string fieldName, object value) { IFieldValidator constraint = Constraints[fieldName]; if (constraint == null) { return true; }//nothing to validate, pass string message; if (constraint.Level == ErrorLevel.Error) { message = constraint.ErrorMessage; } else if (constraint.Level == ErrorLevel.Warning) { message = "Warning::" + constraint.ErrorMessage; } else { message = String.Empty; } if (constraint.Validate(sender, value) == false)//fail validation { sender.AddError(fieldName, message); return false; } else //passes validation { sender.RemoveError(fieldName, message); return true; } }