Skip to content

Commit 28180d8

Browse files
author
alejandro soto
committed
support swift 1.1
1 parent 50e237d commit 28180d8

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

Validator/EmailRule.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class EmailRule: Rule {
2121
}
2222

2323
func validate(value: String) -> Bool {
24-
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
25-
if test.evaluateWithObject(value) {
26-
return true
24+
if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) {
25+
if test.evaluateWithObject(value) {
26+
return true
27+
}
2728
}
2829
return false
2930
}

Validator/MinLengthRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MinLengthRule : Rule {
2222
}
2323

2424
func validate(value: String) -> Bool {
25-
if count(value) < DEFAULT_MIN_LENGTH {
25+
if countElements(value) < DEFAULT_MIN_LENGTH {
2626
return false
2727
}
2828
return true

Validator/PasswordRule.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ class PasswordRule : Rule {
3131
}
3232

3333
func validate(value: String) -> Bool {
34-
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
35-
if test.evaluateWithObject(value) {
36-
return true
34+
if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) {
35+
if test.evaluateWithObject(value) {
36+
return true
37+
}
3738
}
3839
return false
3940
}

Validator/ZipCodeRule.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class ZipCodeRule: Rule {
1919
}
2020

2121
func validate(value: String) -> Bool {
22-
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
23-
if test.evaluateWithObject(value) {
24-
return true
22+
if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) {
23+
if test.evaluateWithObject(value) {
24+
return true
25+
}
2526
}
2627
return false
2728
}

0 commit comments

Comments
 (0)