Ejemplo n.º 1
0
 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;
        }
Ejemplo n.º 3
0
 public void DoubleIsValid(ValidationResult result)
 {
     if (Amount == 10)
         result.SetError("Amount can not be 10");
 }
Ejemplo n.º 4
0
 public void LastNameIsValid(ValidationResult result)
 {
     if(LastName == "Birkholz")
         result.SetError("Bad name");
 }
Ejemplo n.º 5
0
 public void FirstNameIsValid(ValidationResult result)
 {
     if (FirstName == "Joe")
         result.SetError("First Name can not be Joe");
 }