From 5ed3d8c6ba94765280ef3b5e2a67fc39ad532538 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:09:31 -0700 Subject: [PATCH 1/9] Automatic migration to Swift 2.0 Converted using Xcode 7.0 GM release (Version 7A218). --- Validator.xcodeproj/project.pbxproj | 1 + Validator/FloatRule.swift | 4 ++-- Validator/FullNameRule.swift | 2 +- Validator/MaxLengthRule.swift | 2 +- Validator/MinLengthRule.swift | 2 +- Validator/Validator.swift | 4 ++-- Validator/ViewController.swift | 14 +++++++------- ValidatorTests/ValidatorTests.swift | 6 +++--- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 4f69d77..d913b58 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -222,6 +222,7 @@ 62D1AE0F1A1E6D4400E4DFF8 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftMigration = 0700; LastUpgradeCheck = 0610; ORGANIZATIONNAME = jpotts18; TargetAttributes = { diff --git a/Validator/FloatRule.swift b/Validator/FloatRule.swift index 8e5c1f8..f2b84fe 100644 --- a/Validator/FloatRule.swift +++ b/Validator/FloatRule.swift @@ -17,9 +17,9 @@ public class FloatRule:Rule { } public func validate(value: String) -> Bool { - let regex = NSRegularExpression(pattern: "[-+]?(\\d*[.])?\\d+", options: nil, error: nil) + let regex = try? NSRegularExpression(pattern: "[-+]?(\\d*[.])?\\d+", options: []) if let regex = regex { - let match = regex.numberOfMatchesInString(value, options: nil, range: NSRange(location: 0, length: count(value))) + let match = regex.numberOfMatchesInString(value, options: [], range: NSRange(location: 0, length: value.characters.count)) return match == 1 } return false diff --git a/Validator/FullNameRule.swift b/Validator/FullNameRule.swift index 9c79f53..f1feb1d 100644 --- a/Validator/FullNameRule.swift +++ b/Validator/FullNameRule.swift @@ -18,7 +18,7 @@ public class FullNameRule : Rule { } public func validate(value: String) -> Bool { - var nameArray: [String] = split(value) { $0 == " " } + let nameArray: [String] = value.characters.split { $0 == " " }.map { String($0) } return nameArray.count >= 2 } diff --git a/Validator/MaxLengthRule.swift b/Validator/MaxLengthRule.swift index fd29af1..ec8d985 100644 --- a/Validator/MaxLengthRule.swift +++ b/Validator/MaxLengthRule.swift @@ -20,7 +20,7 @@ public class MaxLengthRule: Rule { } public func validate(value: String) -> Bool { - return count(value) <= DEFAULT_LENGTH + return value.characters.count <= DEFAULT_LENGTH } public func errorMessage() -> String { diff --git a/Validator/MinLengthRule.swift b/Validator/MinLengthRule.swift index 3ff63ea..75656c5 100644 --- a/Validator/MinLengthRule.swift +++ b/Validator/MinLengthRule.swift @@ -21,7 +21,7 @@ public class MinLengthRule: Rule { } public func validate(value: String) -> Bool { - return count(value) >= DEFAULT_LENGTH + return value.characters.count >= DEFAULT_LENGTH } public func errorMessage() -> String { diff --git a/Validator/Validator.swift b/Validator/Validator.swift index 6b13934..f9b806c 100644 --- a/Validator/Validator.swift +++ b/Validator/Validator.swift @@ -30,7 +30,7 @@ public class Validator { errors = [:] for (textField, rule) in validations { - if var error = rule.validateField() { + if let error = rule.validateField() { errors[textField] = error // let the user transform the field if they want @@ -49,7 +49,7 @@ public class Validator { // MARK: Using Keys - public func styleTransformers(#success:((validationRule:ValidationRule)->Void)?, error:((validationError:ValidationError)->Void)?) { + public func styleTransformers(success success:((validationRule:ValidationRule)->Void)?, error:((validationError:ValidationError)->Void)?) { self.successStyleTransform = success self.errorStyleTransform = error } diff --git a/Validator/ViewController.swift b/Validator/ViewController.swift index a1097f5..5fa5cd2 100644 --- a/Validator/ViewController.swift +++ b/Validator/ViewController.swift @@ -34,7 +34,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "hideKeyboard")) validator.styleTransformers(success:{ (validationRule) -> Void in - println("here") + print("here") // clear error label validationRule.errorLabel?.hidden = true validationRule.errorLabel?.text = "" @@ -42,7 +42,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate validationRule.textField.layer.borderWidth = 0.5 }, error:{ (validationError) -> Void in - println("error") + print("error") validationError.errorLabel?.hidden = false validationError.errorLabel?.text = validationError.errorMessage validationError.textField.layer.borderColor = UIColor.redColor().CGColor @@ -57,22 +57,22 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate } @IBAction func submitTapped(sender: AnyObject) { - println("Validating...") + print("Validating...") validator.validate(self) } // MARK: ValidationDelegate Methods func validationSuccessful() { - println("Validation Success!") - var alert = UIAlertController(title: "Success", message: "You are validated!", preferredStyle: UIAlertControllerStyle.Alert) - var defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil) + print("Validation Success!") + let alert = UIAlertController(title: "Success", message: "You are validated!", preferredStyle: UIAlertControllerStyle.Alert) + let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil) alert.addAction(defaultAction) self.presentViewController(alert, animated: true, completion: nil) } func validationFailed(errors:[UITextField:ValidationError]) { - println("Validation FAILED!") + print("Validation FAILED!") } func hideKeyboard(){ diff --git a/ValidatorTests/ValidatorTests.swift b/ValidatorTests/ValidatorTests.swift index 8e2e65f..ac3d9a9 100644 --- a/ValidatorTests/ValidatorTests.swift +++ b/ValidatorTests/ValidatorTests.swift @@ -35,15 +35,15 @@ class ValidatorTests: XCTestCase { let LEN_20 = "Paint the cat orange" let REGISTER_TXT_FIELD = UITextField() - let REGISTER_VALIDATOR = Validator() + let REGISTER_VALIDATOR = Validator let REGISTER_RULES = [Rule]() let UNREGISTER_TXT_FIELD = UITextField() - let UNREGISTER_VALIDATOR = Validator() + let UNREGISTER_VALIDATOR = Validator let UNREGISTER_RULES = [Rule]() let UNREGISTER_ERRORS_TXT_FIELD = UITextField() - let UNREGISTER_ERRORS_VALIDATOR = Validator() + let UNREGISTER_ERRORS_VALIDATOR = Validator let ERROR_LABEL = UILabel() From 9b34d138b79becc3f298c192fdd9f260702f8d8b Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 16:49:45 -0700 Subject: [PATCH 2/9] `ValidationError` inherits from `NSObject` `ValidationError` is now an `NSObject` subclass so that `ValidationDelegate` can declare an argument of type `UITextField:ValidationError`. When `ValidationError` is a Swift only class we get a compile error (in Xcode Version 7.0 GM (7A218)): > Validator.swift:14:10: Method cannot be a member of an @objc protocol because the type of the parameter cannot be represented in Objective-C Conflicts: Validator/ValidationError.swift --- Validator/ValidationError.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validator/ValidationError.swift b/Validator/ValidationError.swift index 64cea2a..e6f9c07 100644 --- a/Validator/ValidationError.swift +++ b/Validator/ValidationError.swift @@ -9,7 +9,7 @@ import Foundation import UIKit -public class ValidationError { +public class ValidationError: NSObject { public let textField:UITextField public var errorLabel:UILabel? public let errorMessage:String From b89c188ecc49c947c26e8e2fbe78a096eba98655 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:16:47 -0700 Subject: [PATCH 3/9] `UITextField.text` is now an optional With the Xcode 7 GM release `text` is now an optional despite the documentation stating a default value of "" so we need to unwrap it or provide a default to satisfy the compiler. --- Validator/ValidationRule.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validator/ValidationRule.swift b/Validator/ValidationRule.swift index 88b95ce..c91d209 100644 --- a/Validator/ValidationRule.swift +++ b/Validator/ValidationRule.swift @@ -21,7 +21,7 @@ public class ValidationRule { } public func validateField() -> ValidationError? { - return rules.filter{ !$0.validate(self.textField.text) } + return rules.filter{ !$0.validate(self.textField.text ?? "") } .map{ rule -> ValidationError in return ValidationError(textField: self.textField, errorLabel:self.errorLabel, error: rule.errorMessage()) }.first } } \ No newline at end of file From 1b7c541ed3d4e343a0ab2e3f3e596017fc6701a6 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 16:43:19 -0700 Subject: [PATCH 4/9] Perform recommended update to .pbxproj XCode suggests `ENABLE_TESTABILITY`, and updates to `PRODUCT_BUNDLE_IDENTIFIER` --- Validator.xcodeproj/project.pbxproj | 7 ++++++- Validator/Info.plist | 2 +- ValidatorTests/Info.plist | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index d913b58..9c7a44b 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -223,7 +223,7 @@ isa = PBXProject; attributes = { LastSwiftMigration = 0700; - LastUpgradeCheck = 0610; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = jpotts18; TargetAttributes = { 62D1AE161A1E6D4400E4DFF8 = { @@ -356,6 +356,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -419,6 +420,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Validator/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -429,6 +431,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Validator/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -447,6 +450,7 @@ ); INFOPLIST_FILE = ValidatorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; @@ -462,6 +466,7 @@ ); INFOPLIST_FILE = ValidatorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; diff --git a/Validator/Info.plist b/Validator/Info.plist index 537a546..6905cc6 100644 --- a/Validator/Info.plist +++ b/Validator/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/ValidatorTests/Info.plist b/ValidatorTests/Info.plist index 9ba3dc8..ba72822 100644 --- a/ValidatorTests/Info.plist +++ b/ValidatorTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From 7c31d5fd9e4638ea95b8b85d46b1ccffdf343ebd Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:22:49 -0700 Subject: [PATCH 5/9] Add constructor calls to fix test build errors --- ValidatorTests/ValidatorTests.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ValidatorTests/ValidatorTests.swift b/ValidatorTests/ValidatorTests.swift index ac3d9a9..8e2e65f 100644 --- a/ValidatorTests/ValidatorTests.swift +++ b/ValidatorTests/ValidatorTests.swift @@ -35,15 +35,15 @@ class ValidatorTests: XCTestCase { let LEN_20 = "Paint the cat orange" let REGISTER_TXT_FIELD = UITextField() - let REGISTER_VALIDATOR = Validator + let REGISTER_VALIDATOR = Validator() let REGISTER_RULES = [Rule]() let UNREGISTER_TXT_FIELD = UITextField() - let UNREGISTER_VALIDATOR = Validator + let UNREGISTER_VALIDATOR = Validator() let UNREGISTER_RULES = [Rule]() let UNREGISTER_ERRORS_TXT_FIELD = UITextField() - let UNREGISTER_ERRORS_VALIDATOR = Validator + let UNREGISTER_ERRORS_VALIDATOR = Validator() let ERROR_LABEL = UILabel() From 52a2138dd61d10685009e49f33397ef29df95296 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:23:12 -0700 Subject: [PATCH 6/9] Remove unused framework search path, fix warning --- Validator.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 9c7a44b..2eebee0 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -440,10 +440,6 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -460,10 +456,6 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); INFOPLIST_FILE = ValidatorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; From b4d1a0c24e388989db1fe74af7186626549dc006 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:29:49 -0700 Subject: [PATCH 7/9] Bump podspec version to `3.0.0` A new major release since Swift 2.0 changes are not backwards compatible for anyone using Xcode 6/Swift 1.2. --- SwiftValidator.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SwiftValidator.podspec b/SwiftValidator.podspec index 19f3682..69831c5 100644 --- a/SwiftValidator.podspec +++ b/SwiftValidator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SwiftValidator" - s.version = "2.1.1" + s.version = "3.0.0" s.summary = "A UITextField Validation library for Swift" s.homepage = "https://github.com/jpotts18/SwiftValidator" s.screenshots = "https://raw.githubusercontent.com/jpotts18/SwiftValidator/master/swift-validator-v2.gif" @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.social_media_url = "http://twitter.com/jpotts18" s.platform = :ios s.ios.deployment_target = '8.0' - s.source = { :git => "https://github.com/jpotts18/SwiftValidator.git", :tag => "2.1.1" } + s.source = { :git => "https://github.com/jpotts18/SwiftValidator.git", :tag => "3.0.0" } s.source_files = "Validator/*.swift" s.frameworks = ['Foundation', 'UIKit'] s.requires_arc = true From 2b342f88847c95d942713453c255770d875c636b Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:36:00 -0700 Subject: [PATCH 8/9] Add missing phone number rule to project --- Validator.xcodeproj/project.pbxproj | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 2eebee0..2118038 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 62DC8D6E1AAA42CE0095DFA7 /* PasswordRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62DC8D6B1AAA42CE0095DFA7 /* PasswordRule.swift */; }; 62DC8D711AAA43110095DFA7 /* ZipCodeRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62DC8D701AAA43110095DFA7 /* ZipCodeRule.swift */; }; 62E9E2AD1ACFB336000A939C /* RegexRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E9E2AC1ACFB336000A939C /* RegexRule.swift */; }; + D7C1D97E1BA25940008CE686 /* PhoneNumberRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C1D97D1BA25940008CE686 /* PhoneNumberRule.swift */; settings = {ASSET_TAGS = (); }; }; DC5A35EC1AF99BA60013FE6B /* FloatRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5A35EB1AF99BA60013FE6B /* FloatRule.swift */; }; /* End PBXBuildFile section */ @@ -63,6 +64,7 @@ 62DC8D6B1AAA42CE0095DFA7 /* PasswordRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordRule.swift; sourceTree = ""; }; 62DC8D701AAA43110095DFA7 /* ZipCodeRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZipCodeRule.swift; sourceTree = ""; }; 62E9E2AC1ACFB336000A939C /* RegexRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegexRule.swift; sourceTree = ""; }; + D7C1D97D1BA25940008CE686 /* PhoneNumberRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberRule.swift; sourceTree = ""; }; DC5A35EB1AF99BA60013FE6B /* FloatRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FloatRule.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -163,17 +165,18 @@ 62DC8D661AAA42700095DFA7 /* Rules */ = { isa = PBXGroup; children = ( + 628637271AAA49E300BC8FCF /* ConfirmRule.swift */, + 62DC8D691AAA42CE0095DFA7 /* EmailRule.swift */, + DC5A35EB1AF99BA60013FE6B /* FloatRule.swift */, + 62DC8D671AAA42920095DFA7 /* FullNameRule.swift */, 623F29931AD836E6005B26CB /* MaxLengthRule.swift */, 628637251AAA474B00BC8FCF /* MinLengthRule.swift */, - 62DC8D641AAA42520095DFA7 /* Rule.swift */, - 62DC8D691AAA42CE0095DFA7 /* EmailRule.swift */, - 62DC8D6A1AAA42CE0095DFA7 /* RequiredRule.swift */, 62DC8D6B1AAA42CE0095DFA7 /* PasswordRule.swift */, - 62DC8D671AAA42920095DFA7 /* FullNameRule.swift */, - 62DC8D701AAA43110095DFA7 /* ZipCodeRule.swift */, - 628637271AAA49E300BC8FCF /* ConfirmRule.swift */, + D7C1D97D1BA25940008CE686 /* PhoneNumberRule.swift */, 62E9E2AC1ACFB336000A939C /* RegexRule.swift */, - DC5A35EB1AF99BA60013FE6B /* FloatRule.swift */, + 62DC8D6A1AAA42CE0095DFA7 /* RequiredRule.swift */, + 62DC8D641AAA42520095DFA7 /* Rule.swift */, + 62DC8D701AAA43110095DFA7 /* ZipCodeRule.swift */, ); name = Rules; sourceTree = ""; @@ -284,6 +287,7 @@ 62D1AE4F1A1E6FF800E4DFF8 /* ValidationError.swift in Sources */, 62DC8D6E1AAA42CE0095DFA7 /* PasswordRule.swift in Sources */, 62DC8D6C1AAA42CE0095DFA7 /* EmailRule.swift in Sources */, + D7C1D97E1BA25940008CE686 /* PhoneNumberRule.swift in Sources */, 628637281AAA49E300BC8FCF /* ConfirmRule.swift in Sources */, 62DC8D651AAA42520095DFA7 /* Rule.swift in Sources */, 62D1AE1F1A1E6D4400E4DFF8 /* ViewController.swift in Sources */, From 45da08a089be78663f9f98605268a996faeaace7 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 10 Sep 2015 17:36:23 -0700 Subject: [PATCH 9/9] Convert `var` to `let`, resolve warning. --- Validator/PhoneNumberRule.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validator/PhoneNumberRule.swift b/Validator/PhoneNumberRule.swift index 10b555a..4c6f524 100644 --- a/Validator/PhoneNumberRule.swift +++ b/Validator/PhoneNumberRule.swift @@ -17,7 +17,7 @@ class PhoneNumberRule: Rule { } func validate(value: String) -> Bool { - var phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX) + let phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX) return phoneTest.evaluateWithObject(value) }