fixes for compatibility with swift 1.2

This commit is contained in:
Dmitry Zarva 2015-04-11 23:26:23 +03:00
parent 0c50381640
commit 0497bbbbe0
4 changed files with 6 additions and 15 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {