diff --git a/Validator/EmailRule.swift b/Validator/EmailRule.swift index dbb9252..4203a2a 100644 --- a/Validator/EmailRule.swift +++ b/Validator/EmailRule.swift @@ -21,9 +21,10 @@ class EmailRule: Rule { } func validate(value: String) -> Bool { - let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) - if test.evaluateWithObject(value) { - return true + if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) { + if test.evaluateWithObject(value) { + return true + } } return false } diff --git a/Validator/MinLengthRule.swift b/Validator/MinLengthRule.swift index 0c94f4a..4971000 100644 --- a/Validator/MinLengthRule.swift +++ b/Validator/MinLengthRule.swift @@ -22,7 +22,7 @@ class MinLengthRule : Rule { } func validate(value: String) -> Bool { - if count(value) < DEFAULT_MIN_LENGTH { + if countElements(value) < DEFAULT_MIN_LENGTH { return false } return true diff --git a/Validator/PasswordRule.swift b/Validator/PasswordRule.swift index 5eb3b00..5dbe149 100644 --- a/Validator/PasswordRule.swift +++ b/Validator/PasswordRule.swift @@ -31,9 +31,10 @@ class PasswordRule : Rule { } func validate(value: String) -> Bool { - let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) - if test.evaluateWithObject(value) { - return true + if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) { + if test.evaluateWithObject(value) { + return true + } } return false } diff --git a/Validator/ZipCodeRule.swift b/Validator/ZipCodeRule.swift index 4990483..4d35c30 100644 --- a/Validator/ZipCodeRule.swift +++ b/Validator/ZipCodeRule.swift @@ -19,9 +19,10 @@ class ZipCodeRule: Rule { } func validate(value: String) -> Bool { - let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) - if test.evaluateWithObject(value) { - return true + if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) { + if test.evaluateWithObject(value) { + return true + } } return false }