public static Exception Validate(this IFiledList fields) { Exception error = null; foreach (var field in fields) { if (!field.IsValid) { error = field.Error; break; } } return(error); }
public static List <Exception> ValidateAll(this IFiledList fields) { List <Exception> errors = null; foreach (var field in fields) { if (!field.IsValid) { if (errors == null) { errors = new List <Exception>(); } errors.Add(field.Error); break; } } return(errors); }