support swift 1.1

This commit is contained in:
alejandro soto 2015-03-30 14:23:24 -06:00
parent 50e237d7f3
commit 28180d899c
4 changed files with 13 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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