From 28180d899c83877ea96dc7b49ec4f572f98b02c1 Mon Sep 17 00:00:00 2001 From: alejandro soto Date: Mon, 30 Mar 2015 14:23:24 -0600 Subject: [PATCH] support swift 1.1 --- Validator/EmailRule.swift | 7 ++++--- Validator/MinLengthRule.swift | 2 +- Validator/PasswordRule.swift | 7 ++++--- Validator/ZipCodeRule.swift | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) 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 }