From 0497bbbbe0fd0bfe144753bcf5dcb4cb58a90b53 Mon Sep 17 00:00:00 2001 From: Dmitry Zarva Date: Sat, 11 Apr 2015 23:26:23 +0300 Subject: [PATCH] fixes for compatibility with swift 1.2 --- Validator/MaxLengthRule.swift | 2 +- Validator/MinLengthRule.swift | 2 +- Validator/PhoneNumberRule.swift | 9 ++------- Validator/RegexRule.swift | 8 ++------ 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Validator/MaxLengthRule.swift b/Validator/MaxLengthRule.swift index b9bcee5..f6b346a 100644 --- a/Validator/MaxLengthRule.swift +++ b/Validator/MaxLengthRule.swift @@ -18,7 +18,7 @@ public class MaxLengthRule: Rule { } public func validate(value: String) -> Bool { - return countElements(value) <= DEFAULT_LENGTH + return count(value) <= DEFAULT_LENGTH } public func errorMessage() -> String { diff --git a/Validator/MinLengthRule.swift b/Validator/MinLengthRule.swift index 952e0ce..c5cf308 100644 --- a/Validator/MinLengthRule.swift +++ b/Validator/MinLengthRule.swift @@ -19,7 +19,7 @@ public class MinLengthRule: Rule { } public func validate(value: String) -> Bool { - return countElements(value) >= DEFAULT_LENGTH + return count(value) >= DEFAULT_LENGTH } public func errorMessage() -> String { diff --git a/Validator/PhoneNumberRule.swift b/Validator/PhoneNumberRule.swift index 65cd113..10b555a 100644 --- a/Validator/PhoneNumberRule.swift +++ b/Validator/PhoneNumberRule.swift @@ -17,13 +17,8 @@ class PhoneNumberRule: Rule { } func validate(value: String) -> Bool { - if let phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX) { - if phoneTest.evaluateWithObject(value) { - return true - } - return false - } - return false + var phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX) + return phoneTest.evaluateWithObject(value) } func errorMessage() -> String { diff --git a/Validator/RegexRule.swift b/Validator/RegexRule.swift index 2f10190..af00238 100644 --- a/Validator/RegexRule.swift +++ b/Validator/RegexRule.swift @@ -17,12 +17,8 @@ public class RegexRule : Rule { } public func validate(value: String) -> Bool { - if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) { - if test.evaluateWithObject(value) { - return true - } - } - return false + let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) + return test.evaluateWithObject(value) } public func errorMessage() -> String {