support swift 1.1
This commit is contained in:
parent
50e237d7f3
commit
28180d899c
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue