diff --git a/Validator/ValidationRule.swift b/Validator/ValidationRule.swift index eb0e333..88b95ce 100644 --- a/Validator/ValidationRule.swift +++ b/Validator/ValidationRule.swift @@ -21,11 +21,7 @@ public class ValidationRule { } public func validateField() -> ValidationError? { - for rule in rules { - if !rule.validate(textField.text) { - return ValidationError(textField: self.textField, errorLabel:self.errorLabel, error: rule.errorMessage()) - } - } - return nil + return rules.filter{ !$0.validate(self.textField.text) } + .map{ rule -> ValidationError in return ValidationError(textField: self.textField, errorLabel:self.errorLabel, error: rule.errorMessage()) }.first } } \ No newline at end of file