示例#1
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (Address1 != null && Address2 != null && Address2.ToLower() == Address1.ToLower())
     {
         yield return(new ValidationResult("Address 2 cannot be the same as Address 1."));
     }
     if (State != null && State.Length != 2)
     {
         yield return(new ValidationResult("Enter a 2 digit State code."));
     }
     if (Zipcode != null && Zipcode.Length != 5)
     {
         yield return(new ValidationResult("Enter a 5 digit Zipcode."));
     }
 }