Skip to content

Commit 17c0923

Browse files
committed
Merge pull request #17 from zarv1k/swift1.2
fixes for compatibility with swift 1.2
2 parents 62c0706 + 0497bbb commit 17c0923

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

Validator/MaxLengthRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class MaxLengthRule: Rule {
1818
}
1919

2020
public func validate(value: String) -> Bool {
21-
return countElements(value) <= DEFAULT_LENGTH
21+
return count(value) <= DEFAULT_LENGTH
2222
}
2323

2424
public func errorMessage() -> String {

Validator/MinLengthRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class MinLengthRule: Rule {
1919
}
2020

2121
public func validate(value: String) -> Bool {
22-
return countElements(value) >= DEFAULT_LENGTH
22+
return count(value) >= DEFAULT_LENGTH
2323
}
2424

2525
public func errorMessage() -> String {

Validator/PhoneNumberRule.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@ class PhoneNumberRule: Rule {
1717
}
1818

1919
func validate(value: String) -> Bool {
20-
if let phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX) {
21-
if phoneTest.evaluateWithObject(value) {
22-
return true
23-
}
24-
return false
25-
}
26-
return false
20+
var phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
21+
return phoneTest.evaluateWithObject(value)
2722
}
2823

2924
func errorMessage() -> String {

Validator/RegexRule.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ public class RegexRule : Rule {
1717
}
1818

1919
public func validate(value: String) -> Bool {
20-
if let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) {
21-
if test.evaluateWithObject(value) {
22-
return true
23-
}
24-
}
25-
return false
20+
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
21+
return test.evaluateWithObject(value)
2622
}
2723

2824
public func errorMessage() -> String {

0 commit comments

Comments
 (0)