public void AmountIsValid(ValidationResult result) { Console.WriteLine("Amount {0}", Amount); if (Amount < 0) { result.SetError("Amount must be greater than 0"); } }
string GetErrorFor(string columnName) { var methodName = string.Format("{0}IsValid", columnName); var typeWithMethod = _Instance.GetType(); var method = typeWithMethod.GetMethod(methodName); if (method == null) return string.Empty; var result = new ValidationResult(); method.Invoke(_Instance, new object[] {result}); return (result.IsValid) ? string.Empty : result.Message; }
public void DoubleIsValid(ValidationResult result) { if (Amount == 10) result.SetError("Amount can not be 10"); }
public void LastNameIsValid(ValidationResult result) { if(LastName == "Birkholz") result.SetError("Bad name"); }
public void FirstNameIsValid(ValidationResult result) { if (FirstName == "Joe") result.SetError("First Name can not be Joe"); }