From 8339c8c086216096a2e910903a1f599b405cdd8b Mon Sep 17 00:00:00 2001 From: ed-mejia Date: Mon, 8 Aug 2016 17:26:41 +1000 Subject: [PATCH 01/29] Fixes to support Swift 3 Xcode Beta 4 --- SwiftValidator/Core/Validatable.swift | 2 +- SwiftValidator/Core/ValidationDelegate.swift | 2 +- SwiftValidator/Core/Validator.swift | 12 +++---- SwiftValidator/Core/ValidatorDictionary.swift | 10 +++--- SwiftValidator/Rules/AlphaNumericRule.swift | 4 +-- SwiftValidator/Rules/AlphaRule.swift | 4 +-- SwiftValidator/Rules/CharacterSetRule.swift | 10 +++--- SwiftValidator/Rules/ConfirmRule.swift | 4 +-- SwiftValidator/Rules/ExactLengthRule.swift | 4 +-- SwiftValidator/Rules/FloatRule.swift | 4 +-- SwiftValidator/Rules/FullNameRule.swift | 4 +-- SwiftValidator/Rules/ISBNRule.swift | 32 +++++++++---------- SwiftValidator/Rules/MaxLengthRule.swift | 2 +- SwiftValidator/Rules/MinLengthRule.swift | 2 +- SwiftValidator/Rules/RegexRule.swift | 4 +-- SwiftValidator/Rules/RequiredRule.swift | 4 +-- SwiftValidator/Rules/Rule.swift | 2 +- SwiftValidatorTests/SwiftValidatorTests.swift | 10 +++--- Validator.xcodeproj/project.pbxproj | 23 ++++++++++++- .../xcschemes/SwiftValidator.xcscheme | 2 +- .../xcschemes/SwiftValidatorTests.xcscheme | 2 +- .../xcshareddata/xcschemes/Validator.xcscheme | 2 +- Validator/AppDelegate.swift | 12 +++---- Validator/ViewController.swift | 24 +++++++------- 24 files changed, 101 insertions(+), 80 deletions(-) diff --git a/SwiftValidator/Core/Validatable.swift b/SwiftValidator/Core/Validatable.swift index 6a37253..3ca537e 100644 --- a/SwiftValidator/Core/Validatable.swift +++ b/SwiftValidator/Core/Validatable.swift @@ -8,7 +8,7 @@ import Foundation -public typealias ValidatableField = protocol +public typealias ValidatableField = AnyObject & Validatable public protocol Validatable { diff --git a/SwiftValidator/Core/ValidationDelegate.swift b/SwiftValidator/Core/ValidationDelegate.swift index edda1ec..0e073ed 100644 --- a/SwiftValidator/Core/ValidationDelegate.swift +++ b/SwiftValidator/Core/ValidationDelegate.swift @@ -23,5 +23,5 @@ public protocol ValidationDelegate { - returns: No return value. */ - func validationFailed(errors: [(Validatable, ValidationError)]) + func validationFailed(_ errors: [(Validatable, ValidationError)]) } diff --git a/SwiftValidator/Core/Validator.swift b/SwiftValidator/Core/Validator.swift index 411316f..a7a1262 100644 --- a/SwiftValidator/Core/Validator.swift +++ b/SwiftValidator/Core/Validator.swift @@ -65,7 +65,7 @@ public class Validator { - parameter field: Holds validator field data. - returns: No return value. */ - public func validateField(field: ValidatableField, callback: (error:ValidationError?) -> Void){ + public func validateField(_ field: ValidatableField, callback: (error:ValidationError?) -> Void){ if let fieldRule = validations[field] { if let error = fieldRule.validateField() { errors[field] = error @@ -93,7 +93,7 @@ public class Validator { - parameter error: A closure which is called with validationError, an object that holds validation error data - returns: No return value */ - public func styleTransformers(success success:((validationRule:ValidationRule)->Void)?, error:((validationError:ValidationError)->Void)?) { + public func styleTransformers(success:((validationRule:ValidationRule)->Void)?, error:((validationError:ValidationError)->Void)?) { self.successStyleTransform = success self.errorStyleTransform = error } @@ -106,7 +106,7 @@ public class Validator { - parameter rules: A Rule array that holds different rules that apply to said field. - returns: No return value */ - public func registerField(field: ValidatableField, errorLabel:UILabel? = nil, rules:[Rule]) { + public func registerField(_ field: ValidatableField, errorLabel:UILabel? = nil, rules:[Rule]) { validations[field] = ValidationRule(field: field, rules:rules, errorLabel:errorLabel) fields[field] = field } @@ -117,7 +117,7 @@ public class Validator { - parameter field: field used to locate and remove field from validator. - returns: No return value */ - public func unregisterField(field:ValidatableField) { + public func unregisterField(_ field:ValidatableField) { validations.removeValueForKey(field) errors.removeValueForKey(field) } @@ -127,7 +127,7 @@ public class Validator { - returns: No return value. */ - public func validate(delegate:ValidationDelegate) { + public func validate(_ delegate:ValidationDelegate) { self.validateAllFields() @@ -145,7 +145,7 @@ public class Validator { - parameter callback: A closure which is called with errors, a dictionary of type Validatable:ValidationError. - returns: No return value. */ - public func validate(callback:(errors:[(Validatable, ValidationError)])->Void) -> Void { + public func validate(_ callback:(errors:[(Validatable, ValidationError)])->Void) -> Void { self.validateAllFields() diff --git a/SwiftValidator/Core/ValidatorDictionary.swift b/SwiftValidator/Core/ValidatorDictionary.swift index baab892..e152b0f 100644 --- a/SwiftValidator/Core/ValidatorDictionary.swift +++ b/SwiftValidator/Core/ValidatorDictionary.swift @@ -8,7 +8,7 @@ import Foundation -public struct ValidatorDictionary : SequenceType { +public struct ValidatorDictionary : Sequence { private var innerDictionary: [ObjectIdentifier: T] = [:]; @@ -31,15 +31,15 @@ public struct ValidatorDictionary : SequenceType { innerDictionary.removeAll() } - public mutating func removeValueForKey(key: ValidatableField) { - innerDictionary.removeValueForKey(ObjectIdentifier(key)) + public mutating func removeValueForKey(_ key: ValidatableField) { + innerDictionary.removeValue(forKey: ObjectIdentifier(key)) } public var isEmpty: Bool { return innerDictionary.isEmpty } - public func generate() -> DictionaryGenerator { - return innerDictionary.generate() + public func makeIterator() -> DictionaryIterator { + return innerDictionary.makeIterator() } } diff --git a/SwiftValidator/Rules/AlphaNumericRule.swift b/SwiftValidator/Rules/AlphaNumericRule.swift index d21dfe8..ba8f017 100644 --- a/SwiftValidator/Rules/AlphaNumericRule.swift +++ b/SwiftValidator/Rules/AlphaNumericRule.swift @@ -21,6 +21,6 @@ public class AlphaNumericRule: CharacterSetRule { - returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception. */ public init(message: String = "Enter valid numeric characters") { - super.init(characterSet: NSCharacterSet.alphanumericCharacterSet(), message: message) + super.init(characterSet: CharacterSet.alphanumerics, message: message) } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/AlphaRule.swift b/SwiftValidator/Rules/AlphaRule.swift index 963ea8c..3e9c4cd 100644 --- a/SwiftValidator/Rules/AlphaRule.swift +++ b/SwiftValidator/Rules/AlphaRule.swift @@ -21,6 +21,6 @@ public class AlphaRule: CharacterSetRule { - returns: An initialized object, or nil if an object could not be created for some reason. */ public init(message: String = "Enter valid alphabetic characters") { - super.init(characterSet: NSCharacterSet.letterCharacterSet(), message: message) + super.init(characterSet: CharacterSet.letters, message: message) } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/CharacterSetRule.swift b/SwiftValidator/Rules/CharacterSetRule.swift index cba73f0..01ec8b0 100644 --- a/SwiftValidator/Rules/CharacterSetRule.swift +++ b/SwiftValidator/Rules/CharacterSetRule.swift @@ -13,7 +13,7 @@ import Foundation */ public class CharacterSetRule: Rule { /// NSCharacter that hold set of valid characters to hold - private let characterSet: NSCharacterSet + private let characterSet: CharacterSet /// String that holds error message private var message: String @@ -24,7 +24,7 @@ public class CharacterSetRule: Rule { - parameter message: String of error message. - returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception. */ - public init(characterSet: NSCharacterSet, message: String = "Enter valid alpha") { + public init(characterSet: CharacterSet, message: String = "Enter valid alpha") { self.characterSet = characterSet self.message = message } @@ -35,9 +35,9 @@ public class CharacterSetRule: Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { for uni in value.unicodeScalars { - if !characterSet.longCharacterIsMember(uni.value) { + if !characterSet.contains(UnicodeScalar(uni.value)) { return false } } @@ -52,4 +52,4 @@ public class CharacterSetRule: Rule { public func errorMessage() -> String { return message } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/ConfirmRule.swift b/SwiftValidator/Rules/ConfirmRule.swift index 0df85f8..52f136d 100644 --- a/SwiftValidator/Rules/ConfirmRule.swift +++ b/SwiftValidator/Rules/ConfirmRule.swift @@ -37,7 +37,7 @@ public class ConfirmationRule: Rule { - parameter value: String to checked for validation. - returns: A boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { return confirmField.validationText == value } @@ -49,4 +49,4 @@ public class ConfirmationRule: Rule { public func errorMessage() -> String { return message } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/ExactLengthRule.swift b/SwiftValidator/Rules/ExactLengthRule.swift index c19d128..d5b2b33 100644 --- a/SwiftValidator/Rules/ExactLengthRule.swift +++ b/SwiftValidator/Rules/ExactLengthRule.swift @@ -35,7 +35,7 @@ public class ExactLengthRule : Rule { - parameter value: String to checked for validation. - returns: A boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { return value.characters.count == length } @@ -47,4 +47,4 @@ public class ExactLengthRule : Rule { public func errorMessage() -> String { return message } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/FloatRule.swift b/SwiftValidator/Rules/FloatRule.swift index 13dea82..cf30557 100644 --- a/SwiftValidator/Rules/FloatRule.swift +++ b/SwiftValidator/Rules/FloatRule.swift @@ -31,10 +31,10 @@ public class FloatRule:Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { let regex = try? NSRegularExpression(pattern: "^[-+]?(\\d*[.])?\\d+$", options: []) if let regex = regex { - let match = regex.numberOfMatchesInString(value, options: [], range: NSRange(location: 0, length: value.characters.count)) + let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.characters.count)) return match == 1 } return false diff --git a/SwiftValidator/Rules/FullNameRule.swift b/SwiftValidator/Rules/FullNameRule.swift index 0d7a5c8..b9894e0 100644 --- a/SwiftValidator/Rules/FullNameRule.swift +++ b/SwiftValidator/Rules/FullNameRule.swift @@ -30,7 +30,7 @@ public class FullNameRule : Rule { - parameter value: String to checked for validation. - returns: A boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { let nameArray: [String] = value.characters.split { $0 == " " }.map { String($0) } return nameArray.count >= 2 } @@ -43,4 +43,4 @@ public class FullNameRule : Rule { public func errorMessage() -> String { return message } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/ISBNRule.swift b/SwiftValidator/Rules/ISBNRule.swift index a9d724b..f715cdf 100644 --- a/SwiftValidator/Rules/ISBNRule.swift +++ b/SwiftValidator/Rules/ISBNRule.swift @@ -32,13 +32,13 @@ public class ISBNRule: Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { guard let regex = try? NSRegularExpression(pattern: "[\\s-]", options: []) else { fatalError("Invalid ISBN sanitizing regex") } - let sanitized = regex.stringByReplacingMatchesInString(value, options: [], range: NSMakeRange(0, value.characters.count), withTemplate: "") + let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.characters.count), withTemplate: "") return ISBN10Validator().verify(sanitized) || ISBN13Validator().verify(sanitized) } @@ -67,7 +67,7 @@ private protocol ISBNValidator { - returns: A `Bool` that represents what happened during verification. `false` is returned if it fails, `true` is returned if it was a success. */ - func verify(input: String) -> Bool + func verify(_ input: String) -> Bool /** Method that verifies regular expression is valid. @@ -75,7 +75,7 @@ private protocol ISBNValidator { - returns: A `Bool` that represents the status of the ISBN number. `false` if ISBN number was not valid, `true` if it was valid. */ - func checkRegex(input: String) -> Bool + func checkRegex(_ input: String) -> Bool /** Method that verifies `ISBN` being validated is itself valid. It has to be either ISBN10 @@ -85,7 +85,7 @@ private protocol ISBNValidator { - returns: A `Bool` that represents the status of the ISBN number. `false` if ISBN number was not valid, `true` if it was valid. */ - func verifyChecksum(input: String) -> Bool + func verifyChecksum(_ input: String) -> Bool } /** @@ -100,7 +100,7 @@ extension ISBNValidator { - returns: A `Bool` that represents what happened during verification. `false` is returned if it fails, `true` is returned if it was a success. */ - func verify(input: String) -> Bool { + func verify(_ input: String) -> Bool { return checkRegex(input) && verifyChecksum(input) } @@ -112,8 +112,8 @@ extension ISBNValidator { - returns: A `Bool` that represents the status of the ISBN number. `false` if ISBN number was not valid, `true` if it was valid. */ - func checkRegex(input: String) -> Bool { - guard let _ = input.rangeOfString(regex, options: [.RegularExpressionSearch, .AnchoredSearch]) else { + func checkRegex(_ input: String) -> Bool { + guard let _ = input.range(of: regex, options: [.regularExpression, .anchored]) else { return false } @@ -136,19 +136,19 @@ private struct ISBN10Validator: ISBNValidator { - parameter input: String that is checked for ISBN10 validation. - returns: `true` if string is a valid ISBN10 and `false` if it is not. */ - private func verifyChecksum(input: String) -> Bool { + private func verifyChecksum(_ input: String) -> Bool { var checksum = 0 for i in 0..<9 { - if let intCharacter = Int(String(input[input.startIndex.advancedBy(i)])) { + if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) { checksum += (i + 1) * intCharacter } } - if (input[input.startIndex.advancedBy(9)] == "X") { + if (input[input.characters.index(input.startIndex, offsetBy: 9)] == "X") { checksum += 10 * 10 } else { - if let intCharacter = Int(String(input[input.startIndex.advancedBy(9)])) { + if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: 9)])) { checksum += 10 * intCharacter } } @@ -171,21 +171,21 @@ private struct ISBN13Validator: ISBNValidator { - parameter input: String that is checked for ISBN13 validation. - returns: `true` if string is a valid ISBN13 and `false` if it is not. */ - private func verifyChecksum(input: String) -> Bool { + private func verifyChecksum(_ input: String) -> Bool { let factor = [1, 3] var checksum = 0 for i in 0..<12 { - if let intCharacter = Int(String(input[input.startIndex.advancedBy(i)])) { + if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) { print("\(factor[i%2]) * \(intCharacter)") checksum += factor[i % 2] * intCharacter } } - if let lastInt = Int(String(input[input.startIndex.advancedBy(12)])) { + if let lastInt = Int(String(input[input.characters.index(input.startIndex, offsetBy: 12)])) { return (lastInt - ((10 - (checksum % 10)) % 10) == 0) } return false } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/MaxLengthRule.swift b/SwiftValidator/Rules/MaxLengthRule.swift index aea2b2a..43aa535 100644 --- a/SwiftValidator/Rules/MaxLengthRule.swift +++ b/SwiftValidator/Rules/MaxLengthRule.swift @@ -36,7 +36,7 @@ public class MaxLengthRule: Rule { - parameter value: String to checked for validation. - returns: A boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { return value.characters.count <= DEFAULT_LENGTH } diff --git a/SwiftValidator/Rules/MinLengthRule.swift b/SwiftValidator/Rules/MinLengthRule.swift index 300c5d3..e13a330 100644 --- a/SwiftValidator/Rules/MinLengthRule.swift +++ b/SwiftValidator/Rules/MinLengthRule.swift @@ -37,7 +37,7 @@ public class MinLengthRule: Rule { - parameter value: String to checked for validation. - returns: A boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { return value.characters.count >= DEFAULT_LENGTH } diff --git a/SwiftValidator/Rules/RegexRule.swift b/SwiftValidator/Rules/RegexRule.swift index 3a4bbfe..697c626 100644 --- a/SwiftValidator/Rules/RegexRule.swift +++ b/SwiftValidator/Rules/RegexRule.swift @@ -35,9 +35,9 @@ public class RegexRule : Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) - return test.evaluateWithObject(value) + return test.evaluate(with: value) } /** diff --git a/SwiftValidator/Rules/RequiredRule.swift b/SwiftValidator/Rules/RequiredRule.swift index 519cc06..ace8ee5 100644 --- a/SwiftValidator/Rules/RequiredRule.swift +++ b/SwiftValidator/Rules/RequiredRule.swift @@ -31,7 +31,7 @@ public class RequiredRule: Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(value: String) -> Bool { + public func validate(_ value: String) -> Bool { return !value.isEmpty } @@ -43,4 +43,4 @@ public class RequiredRule: Rule { public func errorMessage() -> String { return message } -} \ No newline at end of file +} diff --git a/SwiftValidator/Rules/Rule.swift b/SwiftValidator/Rules/Rule.swift index 6d401ea..2f621c9 100644 --- a/SwiftValidator/Rules/Rule.swift +++ b/SwiftValidator/Rules/Rule.swift @@ -17,7 +17,7 @@ public protocol Rule { - parameter value: String of text to be validated. - returns: Boolean value. True if validation is successful; False if validation fails. */ - func validate(value: String) -> Bool + func validate(_ value: String) -> Bool /** Displays error message of a field that has failed validation. diff --git a/SwiftValidatorTests/SwiftValidatorTests.swift b/SwiftValidatorTests/SwiftValidatorTests.swift index c8a7574..1b063e9 100644 --- a/SwiftValidatorTests/SwiftValidatorTests.swift +++ b/SwiftValidatorTests/SwiftValidatorTests.swift @@ -385,9 +385,9 @@ class SwiftValidatorTests: XCTestCase { var successCount = 0 var errorCount = 0 REGISTER_VALIDATOR.styleTransformers(success: { (validationRule) -> Void in - successCount++ + successCount+=1 }) { (validationError) -> Void in - errorCount++ + errorCount+=1 } REGISTER_TXT_FIELD.text = INVALID_EMAIL REGISTER_VALIDATOR.validate { (errors) -> Void in @@ -403,9 +403,9 @@ class SwiftValidatorTests: XCTestCase { var successCount = 0 var errorCount = 0 REGISTER_VALIDATOR.styleTransformers(success: { (validationRule) -> Void in - successCount++ + successCount+=1 }) { (validationError) -> Void in - errorCount++ + errorCount+=1 } REGISTER_TXT_FIELD.text = INVALID_EMAIL @@ -427,7 +427,7 @@ class SwiftValidatorTests: XCTestCase { REGISTER_TXT_FIELD.text = INVALID_EMAIL REGISTER_VALIDATOR.validate { (errors) -> Void in XCTAssert(errors.count == 1, "Should come back with errors") - XCTAssert(!CGColorEqualToColor(self.REGISTER_TXT_FIELD.layer.borderColor, UIColor.redColor().CGColor), "Color shouldn't get set at all") + XCTAssert(!(self.REGISTER_TXT_FIELD.layer.borderColor! == UIColor.red.cgColor), "Color shouldn't get set at all") } } } diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 8a746c7..17b420c 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -396,21 +396,25 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = jpotts18; TargetAttributes = { 62D1AE161A1E6D4400E4DFF8 = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; }; 62D1AE2B1A1E6D4500E4DFF8 = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; TestTargetID = 62D1AE161A1E6D4400E4DFF8; }; FB465CB21B9884F400398388 = { CreatedOnToolsVersion = 6.4; + LastSwiftMigration = 0800; }; FB465CBC1B9884F400398388 = { CreatedOnToolsVersion = 6.4; + LastSwiftMigration = 0800; TestTargetID = 62D1AE161A1E6D4400E4DFF8; }; }; @@ -585,8 +589,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -595,6 +601,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -628,8 +635,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -637,6 +646,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -658,6 +668,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -669,6 +680,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -684,6 +697,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -696,6 +710,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; @@ -720,6 +735,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -743,6 +759,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -767,6 +785,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -786,6 +805,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; diff --git a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme index 9f3a7ff..b8b0c59 100644 --- a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme +++ b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme @@ -1,6 +1,6 @@ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/Validator/ViewController.swift b/Validator/ViewController.swift index 263f914..90c1a5d 100644 --- a/Validator/ViewController.swift +++ b/Validator/ViewController.swift @@ -31,24 +31,24 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate override func viewDidLoad() { super.viewDidLoad() - self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "hideKeyboard")) + self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ViewController.hideKeyboard))) validator.styleTransformers(success:{ (validationRule) -> Void in print("here") // clear error label - validationRule.errorLabel?.hidden = true + validationRule.errorLabel?.isHidden = true validationRule.errorLabel?.text = "" if let textField = validationRule.field as? UITextField { - textField.layer.borderColor = UIColor.greenColor().CGColor + textField.layer.borderColor = UIColor.green.cgColor textField.layer.borderWidth = 0.5 } }, error:{ (validationError) -> Void in print("error") - validationError.errorLabel?.hidden = false + validationError.errorLabel?.isHidden = false validationError.errorLabel?.text = validationError.errorMessage if let textField = validationError.field as? UITextField { - textField.layer.borderColor = UIColor.redColor().CGColor + textField.layer.borderColor = UIColor.red.cgColor textField.layer.borderWidth = 1.0 } }) @@ -60,7 +60,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate validator.registerField(zipcodeTextField, errorLabel: zipcodeErrorLabel, rules: [RequiredRule(), ZipCodeRule()]) } - @IBAction func submitTapped(sender: AnyObject) { + @IBAction func submitTapped(_ sender: AnyObject) { print("Validating...") validator.validate(self) } @@ -69,13 +69,13 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate func validationSuccessful() { print("Validation Success!") - let alert = UIAlertController(title: "Success", message: "You are validated!", preferredStyle: UIAlertControllerStyle.Alert) - let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil) + 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) + self.present(alert, animated: true, completion: nil) } - func validationFailed(errors:[(Validatable, ValidationError)]) { + func validationFailed(_ errors:[(Validatable, ValidationError)]) { print("Validation FAILED!") } @@ -85,7 +85,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate // MARK: Validate single field // Don't forget to use UITextFieldDelegate - func textFieldShouldReturn(textField: UITextField) -> Bool { + func textFieldShouldReturn(_ textField: UITextField) -> Bool { validator.validateField(textField){ error in if error == nil { // Field validation was successful @@ -96,4 +96,4 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate return true } -} \ No newline at end of file +} From 90e141e923325137e8dfcb593595388aa66c8665 Mon Sep 17 00:00:00 2001 From: Edinson Mejia Date: Wed, 17 Aug 2016 23:10:13 +1000 Subject: [PATCH 02/29] Fixes to support Xcode Beta 6 --- SwiftValidator/Core/Validator.swift | 26 +++++++++---------- SwiftValidator/Rules/CharacterSetRule.swift | 2 +- SwiftValidator/Rules/ExactLengthRule.swift | 2 +- SwiftValidator/Rules/ISBNRule.swift | 4 +-- SwiftValidator/Rules/MaxLengthRule.swift | 2 +- SwiftValidator/Rules/MinLengthRule.swift | 2 +- SwiftValidator/Rules/ValidationRule.swift | 4 +-- SwiftValidatorTests/SwiftValidatorTests.swift | 2 +- Validator/AppDelegate.swift | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/SwiftValidator/Core/Validator.swift b/SwiftValidator/Core/Validator.swift index a7a1262..2553e47 100644 --- a/SwiftValidator/Core/Validator.swift +++ b/SwiftValidator/Core/Validator.swift @@ -20,9 +20,9 @@ public class Validator { /// Dictionary to hold fields by their object identifiers private var fields = ValidatorDictionary() /// Variable that holds success closure to display positive status of field. - private var successStyleTransform:((validationRule:ValidationRule)->Void)? + private var successStyleTransform:((_ validationRule:ValidationRule)->Void)? /// Variable that holds error closure to display negative status of field. - private var errorStyleTransform:((validationError:ValidationError)->Void)? + private var errorStyleTransform:((_ validationError:ValidationError)->Void)? /// - returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception. public init(){} @@ -44,13 +44,13 @@ public class Validator { // let the user transform the field if they want if let transform = self.errorStyleTransform { - transform(validationError: error) + transform(error) } } else { // No error // let the user transform the field if they want if let transform = self.successStyleTransform { - transform(validationRule: rule) + transform(rule) } } } @@ -65,22 +65,22 @@ public class Validator { - parameter field: Holds validator field data. - returns: No return value. */ - public func validateField(_ field: ValidatableField, callback: (error:ValidationError?) -> Void){ + public func validateField(_ field: ValidatableField, callback: (_ error:ValidationError?) -> Void){ if let fieldRule = validations[field] { if let error = fieldRule.validateField() { errors[field] = error if let transform = self.errorStyleTransform { - transform(validationError: error) + transform(error) } - callback(error: error) + callback(error) } else { if let transform = self.successStyleTransform { - transform(validationRule: fieldRule) + transform(fieldRule) } - callback(error: nil) + callback(nil) } } else { - callback(error: nil) + callback(nil) } } @@ -93,7 +93,7 @@ public class Validator { - parameter error: A closure which is called with validationError, an object that holds validation error data - returns: No return value */ - public func styleTransformers(success:((validationRule:ValidationRule)->Void)?, error:((validationError:ValidationError)->Void)?) { + public func styleTransformers(success:((_ validationRule:ValidationRule)->Void)?, error:((_ validationError:ValidationError)->Void)?) { self.successStyleTransform = success self.errorStyleTransform = error } @@ -145,10 +145,10 @@ public class Validator { - parameter callback: A closure which is called with errors, a dictionary of type Validatable:ValidationError. - returns: No return value. */ - public func validate(_ callback:(errors:[(Validatable, ValidationError)])->Void) -> Void { + public func validate(_ callback:(_ errors:[(Validatable, ValidationError)])->Void) -> Void { self.validateAllFields() - callback(errors: errors.map { (fields[$1.field]!, $1) } ) + callback(errors.map { (fields[$1.field]!, $1) } ) } } diff --git a/SwiftValidator/Rules/CharacterSetRule.swift b/SwiftValidator/Rules/CharacterSetRule.swift index 01ec8b0..d897132 100644 --- a/SwiftValidator/Rules/CharacterSetRule.swift +++ b/SwiftValidator/Rules/CharacterSetRule.swift @@ -37,7 +37,7 @@ public class CharacterSetRule: Rule { */ public func validate(_ value: String) -> Bool { for uni in value.unicodeScalars { - if !characterSet.contains(UnicodeScalar(uni.value)) { + guard let uniVal = UnicodeScalar(uni.value), characterSet.contains(uniVal) else { return false } } diff --git a/SwiftValidator/Rules/ExactLengthRule.swift b/SwiftValidator/Rules/ExactLengthRule.swift index d5b2b33..c9aae6d 100644 --- a/SwiftValidator/Rules/ExactLengthRule.swift +++ b/SwiftValidator/Rules/ExactLengthRule.swift @@ -26,7 +26,7 @@ public class ExactLengthRule : Rule { */ public init(length: Int, message : String = "Must be exactly %ld characters long"){ self.length = length - self.message = NSString(format: message, self.length) as String + self.message = String(format: message, self.length) } /** diff --git a/SwiftValidator/Rules/ISBNRule.swift b/SwiftValidator/Rules/ISBNRule.swift index f715cdf..6f8654f 100644 --- a/SwiftValidator/Rules/ISBNRule.swift +++ b/SwiftValidator/Rules/ISBNRule.swift @@ -136,7 +136,7 @@ private struct ISBN10Validator: ISBNValidator { - parameter input: String that is checked for ISBN10 validation. - returns: `true` if string is a valid ISBN10 and `false` if it is not. */ - private func verifyChecksum(_ input: String) -> Bool { + fileprivate func verifyChecksum(_ input: String) -> Bool { var checksum = 0 for i in 0..<9 { @@ -171,7 +171,7 @@ private struct ISBN13Validator: ISBNValidator { - parameter input: String that is checked for ISBN13 validation. - returns: `true` if string is a valid ISBN13 and `false` if it is not. */ - private func verifyChecksum(_ input: String) -> Bool { + fileprivate func verifyChecksum(_ input: String) -> Bool { let factor = [1, 3] var checksum = 0 diff --git a/SwiftValidator/Rules/MaxLengthRule.swift b/SwiftValidator/Rules/MaxLengthRule.swift index 43aa535..57d9b7b 100644 --- a/SwiftValidator/Rules/MaxLengthRule.swift +++ b/SwiftValidator/Rules/MaxLengthRule.swift @@ -27,7 +27,7 @@ public class MaxLengthRule: Rule { */ public init(length: Int, message : String = "Must be at most %ld characters long"){ self.DEFAULT_LENGTH = length - self.message = NSString(format: message, self.DEFAULT_LENGTH) as String + self.message = String(format: message, self.DEFAULT_LENGTH) } /** diff --git a/SwiftValidator/Rules/MinLengthRule.swift b/SwiftValidator/Rules/MinLengthRule.swift index e13a330..d9e161c 100644 --- a/SwiftValidator/Rules/MinLengthRule.swift +++ b/SwiftValidator/Rules/MinLengthRule.swift @@ -29,7 +29,7 @@ public class MinLengthRule: Rule { */ public init(length: Int, message : String = "Must be at least %ld characters long"){ self.DEFAULT_LENGTH = length - self.message = NSString(format: message, self.DEFAULT_LENGTH) as String + self.message = String(format: message, self.DEFAULT_LENGTH) } /** diff --git a/SwiftValidator/Rules/ValidationRule.swift b/SwiftValidator/Rules/ValidationRule.swift index 9bf2655..ef8d306 100644 --- a/SwiftValidator/Rules/ValidationRule.swift +++ b/SwiftValidator/Rules/ValidationRule.swift @@ -39,7 +39,7 @@ public class ValidationRule { */ public func validateField() -> ValidationError? { return rules.filter{ - return !$0.validate(field.validationText ?? "") + return !$0.validate(field.validationText) }.map{ rule -> ValidationError in return ValidationError(field: self.field, errorLabel:self.errorLabel, error: rule.errorMessage()) }.first } -} \ No newline at end of file +} diff --git a/SwiftValidatorTests/SwiftValidatorTests.swift b/SwiftValidatorTests/SwiftValidatorTests.swift index 1b063e9..fab19bc 100644 --- a/SwiftValidatorTests/SwiftValidatorTests.swift +++ b/SwiftValidatorTests/SwiftValidatorTests.swift @@ -366,7 +366,7 @@ class SwiftValidatorTests: XCTestCase { } REGISTER_TXT_FIELD.text = INVALID_EMAIL REGISTER_VALIDATOR.validateField(REGISTER_TXT_FIELD) { error in - XCTAssert(error?.errorMessage.characters.count > 0, "Should state 'invalid email'") + XCTAssert(error?.errorMessage.characters.count ?? 0 > 0, "Should state 'invalid email'") } } diff --git a/Validator/AppDelegate.swift b/Validator/AppDelegate.swift index 46a16ba..a68462f 100644 --- a/Validator/AppDelegate.swift +++ b/Validator/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } From 68fdfbdac067680cdc290776e7c3977380f514b0 Mon Sep 17 00:00:00 2001 From: ed-mejia Date: Thu, 18 Aug 2016 09:16:16 +1000 Subject: [PATCH 03/29] Updated travis osx_image to xcode8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4c71cce..98fe3be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.1 +osx_image: xcode8 before_install: From 8bf185d820b0ec0ea7b270a0634005d5523f6ed1 Mon Sep 17 00:00:00 2001 From: ed-mejia Date: Thu, 18 Aug 2016 09:34:20 +1000 Subject: [PATCH 04/29] Updated travis OS and Simulator --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98fe3be..ce31c91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_install: script: - pod lib lint - - xcodebuild clean build test -project Validator.xcodeproj -scheme Validator -sdk iphonesimulator9.1 -destination "OS=9.1,name=iPhone 6" -enableCodeCoverage YES | xcpretty + - xcodebuild clean build test -project Validator.xcodeproj -scheme Validator -sdk iphonesimulator10.0 -destination "OS=10.0,name=iPhone 6" -enableCodeCoverage YES | xcpretty after_success: From 55f282fe923659ac70fd246537ec851dd518cf64 Mon Sep 17 00:00:00 2001 From: ed-mejia Date: Thu, 18 Aug 2016 10:43:40 +1000 Subject: [PATCH 05/29] Updated travis file config --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce31c91..173ea9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,16 @@ language: objective-c osx_image: xcode8 +xcode_sdk: iphonesimulator10.0 +xcode_project: Validator.xcodeproj +xcode_scheme: Validator before_install: - gem install xcpretty --no-rdoc --no-ri --no-document --quiet script: - + - xcodebuild clean build test -project Validator.xcodeproj -scheme Validator -sdk iphonesimulator -enableCodeCoverage YES | xcpretty - pod lib lint - - xcodebuild clean build test -project Validator.xcodeproj -scheme Validator -sdk iphonesimulator10.0 -destination "OS=10.0,name=iPhone 6" -enableCodeCoverage YES | xcpretty - after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 4f6e77c0aad54c90958085bfbf28c1d600aa4c3d Mon Sep 17 00:00:00 2001 From: ed-mejia Date: Thu, 18 Aug 2016 11:24:56 +1000 Subject: [PATCH 06/29] Updated travis file --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 173ea9d..dad16da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_install: - gem install xcpretty --no-rdoc --no-ri --no-document --quiet script: - - xcodebuild clean build test -project Validator.xcodeproj -scheme Validator -sdk iphonesimulator -enableCodeCoverage YES | xcpretty + - xcodebuild clean build test -project Validator.xcodeproj -scheme Validator -sdk iphonesimulator -destination "platform=iOS Simulator,OS=10.0,name=iPhone 6" -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO | xcpretty - pod lib lint after_success: From 2c68d3db95861af8afab5ae806d41144f1a6f499 Mon Sep 17 00:00:00 2001 From: David Patterson Date: Wed, 5 Oct 2016 00:41:18 -0500 Subject: [PATCH 07/29] updated cocoapods to 0.32.1 on travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dad16da..761d5a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ xcode_project: Validator.xcodeproj xcode_scheme: Validator before_install: - + - gem install cocoapods -v '0.32.1' - gem install xcpretty --no-rdoc --no-ri --no-document --quiet script: From 2a6c23ad9efd76127f6109445515cb9780e5ad92 Mon Sep 17 00:00:00 2001 From: David Patterson Date: Thu, 6 Oct 2016 01:02:33 -0500 Subject: [PATCH 08/29] Update README.md Updated README to highlight how to use different versions of SwiftValidator. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59808ba..1df8d96 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,16 @@ platform :ios, "8.1" use_frameworks! -# As of 4.0.0, SwiftValidator has been extended beyond UITextField +# Swift 3 +# Extended beyond UITextField +pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :branch => 'master' + +# Swift 2.1 +# Extended beyond UITextField # Note: Installing 4.x.x will break code from 3.x.x pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :tag => '4.0.0' -# For older versions +# Swift 2.1 (limited to UITextField validation) pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :tag => '3.0.5' ``` From 504089c2e260d910b471751c450927605109287d Mon Sep 17 00:00:00 2001 From: Hunter Maximillion Monk Date: Mon, 24 Oct 2016 13:00:22 -0500 Subject: [PATCH 09/29] Add support for 9 digit zip codes --- SwiftValidator/Rules/ZipCodeRule.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SwiftValidator/Rules/ZipCodeRule.swift b/SwiftValidator/Rules/ZipCodeRule.swift index 49b3872..f418db6 100644 --- a/SwiftValidator/Rules/ZipCodeRule.swift +++ b/SwiftValidator/Rules/ZipCodeRule.swift @@ -18,7 +18,7 @@ public class ZipCodeRule: RegexRule { - parameter message: String that holds error message. - returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception. */ - public convenience init(message : String = "Enter a valid 5 digit zipcode"){ - self.init(regex: "\\d{5}", message : message) + public convenience init(message : String = "Enter a valid 5 or 9 digit zipcode"){ + self.init(regex: "\\d{5}(-\\d{4})?", message : message) } -} \ No newline at end of file +} From 678e866fe09de30d7c549eb1bb218905b7c9023b Mon Sep 17 00:00:00 2001 From: abid Date: Mon, 14 Nov 2016 11:17:30 +0000 Subject: [PATCH 10/29] Added support for UITextView validation --- SwiftValidator/Core/Validatable.swift | 8 + SwiftValidatorTests/SwiftValidatorTests.swift | 23 +- Validator/Base.lproj/Main.storyboard | 230 +++++++++++------- Validator/ViewController.swift | 11 +- 4 files changed, 180 insertions(+), 92 deletions(-) diff --git a/SwiftValidator/Core/Validatable.swift b/SwiftValidator/Core/Validatable.swift index 3ca537e..dd7e773 100644 --- a/SwiftValidator/Core/Validatable.swift +++ b/SwiftValidator/Core/Validatable.swift @@ -23,3 +23,11 @@ extension UITextField: Validatable { return text ?? "" } } + +extension UITextView: Validatable { + + public var validationText: String { + return text ?? "" + } +} + diff --git a/SwiftValidatorTests/SwiftValidatorTests.swift b/SwiftValidatorTests/SwiftValidatorTests.swift index fab19bc..3abf9fb 100644 --- a/SwiftValidatorTests/SwiftValidatorTests.swift +++ b/SwiftValidatorTests/SwiftValidatorTests.swift @@ -35,6 +35,7 @@ class SwiftValidatorTests: XCTestCase { let LEN_5 = "Howdy" let LEN_20 = "Paint the cat orange" + let REGISTER_TXT_VIEW = UITextView() let REGISTER_TXT_FIELD = UITextField() let REGISTER_VALIDATOR = Validator() let REGISTER_RULES = [Rule]() @@ -320,13 +321,17 @@ class SwiftValidatorTests: XCTestCase { } // MARK: Register Field - - func testRegisterField(){ + func testRegisterTextView(){ + REGISTER_VALIDATOR.registerField(REGISTER_TXT_VIEW, rules: REGISTER_RULES) + XCTAssert(REGISTER_VALIDATOR.validations[REGISTER_TXT_VIEW] != nil, "Textfield should register") + } + + func testRegisterTextField(){ REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, rules: REGISTER_RULES) XCTAssert(REGISTER_VALIDATOR.validations[REGISTER_TXT_FIELD] != nil, "Textfield should register") } - func testUnregisterField(){ + func testUnregisterTextField(){ UNREGISTER_VALIDATOR.registerField(UNREGISTER_TXT_FIELD, rules: UNREGISTER_RULES) UNREGISTER_VALIDATOR.unregisterField(UNREGISTER_TXT_FIELD) XCTAssert(UNREGISTER_VALIDATOR.validations[UNREGISTER_TXT_FIELD] == nil, "Textfield should unregister") @@ -370,6 +375,18 @@ class SwiftValidatorTests: XCTestCase { } } + func testValidateTextViewField() { + REGISTER_VALIDATOR.registerField(REGISTER_TXT_VIEW, rules: [RequiredRule()]) + REGISTER_TXT_VIEW.text = "Some notes" + REGISTER_VALIDATOR.validateField(REGISTER_TXT_VIEW) { error in + XCTAssert(error == nil, "Should not present error") + } + REGISTER_TXT_VIEW.text = nil + REGISTER_VALIDATOR.validateField(REGISTER_TXT_VIEW) { error in + XCTAssert(error!.errorMessage == "This field is required") + } + } + // MARK: Validate error field gets it's text set to the error, if supplied func testNoErrorMessageSet() { diff --git a/Validator/Base.lproj/Main.storyboard b/Validator/Base.lproj/Main.storyboard index 8efcb7e..35799c5 100644 --- a/Validator/Base.lproj/Main.storyboard +++ b/Validator/Base.lproj/Main.storyboard @@ -1,10 +1,14 @@ - - + + + + + - + + @@ -16,56 +20,62 @@ - + - + - + + - + - + + + + + + + + + + + + + - - - - - - + @@ -224,8 +268,9 @@ - + + @@ -235,18 +280,23 @@ + + + + + @@ -255,6 +305,7 @@ + @@ -266,6 +317,7 @@ + @@ -286,50 +338,50 @@ - + - - + + - - - - - - - - - - - - - - - - - + + - - - + + + + + + + + + + + + - - + + + + + + + + @@ -351,50 +403,50 @@ - + - - + + - - - - - - - - - - - - - - - - - + + - - - + + + + + + + + + + + + - - + + + + + + + + @@ -408,6 +460,8 @@ + + @@ -416,7 +470,7 @@ - + diff --git a/Validator/ViewController.swift b/Validator/ViewController.swift index 90c1a5d..fe0e0da 100644 --- a/Validator/ViewController.swift +++ b/Validator/ViewController.swift @@ -18,6 +18,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate @IBOutlet weak var phoneNumberTextField: UITextField! @IBOutlet weak var zipcodeTextField: UITextField! @IBOutlet weak var emailConfirmTextField: UITextField! + @IBOutlet weak var notesTextView: UITextView! // Error Labels @IBOutlet weak var fullNameErrorLabel: UILabel! @@ -25,6 +26,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate @IBOutlet weak var phoneNumberErrorLabel: UILabel! @IBOutlet weak var zipcodeErrorLabel: UILabel! @IBOutlet weak var emailConfirmErrorLabel: UILabel! + @IBOutlet weak var notesErrorLabel: UILabel! let validator = Validator() @@ -38,10 +40,13 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate // clear error label validationRule.errorLabel?.isHidden = true validationRule.errorLabel?.text = "" + if let textField = validationRule.field as? UITextField { textField.layer.borderColor = UIColor.green.cgColor textField.layer.borderWidth = 0.5 - + } else if let textField = validationRule.field as? UITextView { + textField.layer.borderColor = UIColor.green.cgColor + textField.layer.borderWidth = 0.5 } }, error:{ (validationError) -> Void in print("error") @@ -50,6 +55,9 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate if let textField = validationError.field as? UITextField { textField.layer.borderColor = UIColor.red.cgColor textField.layer.borderWidth = 1.0 + } else if let textField = validationError.field as? UITextView { + textField.layer.borderColor = UIColor.red.cgColor + textField.layer.borderWidth = 1.0 } }) @@ -58,6 +66,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate validator.registerField(emailConfirmTextField, errorLabel: emailConfirmErrorLabel, rules: [RequiredRule(), ConfirmationRule(confirmField: emailTextField)]) validator.registerField(phoneNumberTextField, errorLabel: phoneNumberErrorLabel, rules: [RequiredRule(), MinLengthRule(length: 9)]) validator.registerField(zipcodeTextField, errorLabel: zipcodeErrorLabel, rules: [RequiredRule(), ZipCodeRule()]) + validator.registerField(notesTextView, errorLabel: notesErrorLabel, rules: [RequiredRule()]) } @IBAction func submitTapped(_ sender: AnyObject) { From 696c600dc02b0d481238fd0aeea43991371d1579 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 4 Dec 2016 17:39:39 +0200 Subject: [PATCH 11/29] Update RegexRule + RequiredRule --- SwiftValidator/Rules/RegexRule.swift | 6 +++--- SwiftValidator/Rules/RequiredRule.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SwiftValidator/Rules/RegexRule.swift b/SwiftValidator/Rules/RegexRule.swift index 697c626..fcbc033 100644 --- a/SwiftValidator/Rules/RegexRule.swift +++ b/SwiftValidator/Rules/RegexRule.swift @@ -11,7 +11,7 @@ import Foundation /** `RegexRule` is a subclass of Rule that defines how a regular expression is validated. */ -public class RegexRule : Rule { +open class RegexRule : Rule { /// Regular express string to be used in validation. private var REGEX: String = "^(?=.*?[A-Z]).{8,}$" /// String that holds error message. @@ -35,7 +35,7 @@ public class RegexRule : Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(_ value: String) -> Bool { + open func validate(_ value: String) -> Bool { let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX) return test.evaluate(with: value) } @@ -45,7 +45,7 @@ public class RegexRule : Rule { - returns: String of error message. */ - public func errorMessage() -> String { + open func errorMessage() -> String { return message } } diff --git a/SwiftValidator/Rules/RequiredRule.swift b/SwiftValidator/Rules/RequiredRule.swift index ace8ee5..438232c 100644 --- a/SwiftValidator/Rules/RequiredRule.swift +++ b/SwiftValidator/Rules/RequiredRule.swift @@ -11,7 +11,7 @@ import Foundation /** `RequiredRule` is a subclass of Rule that defines how a required field is validated. */ -public class RequiredRule: Rule { +open class RequiredRule: Rule { /// String that holds error message. private var message : String @@ -31,7 +31,7 @@ public class RequiredRule: Rule { - parameter value: String to checked for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ - public func validate(_ value: String) -> Bool { + open func validate(_ value: String) -> Bool { return !value.isEmpty } @@ -40,7 +40,7 @@ public class RequiredRule: Rule { - returns: String of error message. */ - public func errorMessage() -> String { + open func errorMessage() -> String { return message } } From 0edae8b9a86eef385fb867f81538554d7441156c Mon Sep 17 00:00:00 2001 From: Ify Date: Sun, 15 Jan 2017 08:43:04 +0000 Subject: [PATCH 12/29] Added card expiry month and expiry year rules --- .../Rules/CardExpiryMonthRule.swift | 33 ++++++++++++++++ SwiftValidator/Rules/CardExpiryYearRule.swift | 39 +++++++++++++++++++ SwiftValidator/Rules/IPV4Rule.swift | 2 +- SwiftValidatorTests/SwiftValidatorTests.swift | 36 +++++++++++++++++ Validator.xcodeproj/project.pbxproj | 20 +++++++++- .../xcschemes/SwiftValidator.xcscheme | 2 +- .../xcschemes/SwiftValidatorTests.xcscheme | 2 +- .../xcshareddata/xcschemes/Validator.xcscheme | 2 +- .../AppIcon.appiconset/Contents.json | 10 +++++ 9 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 SwiftValidator/Rules/CardExpiryMonthRule.swift create mode 100644 SwiftValidator/Rules/CardExpiryYearRule.swift diff --git a/SwiftValidator/Rules/CardExpiryMonthRule.swift b/SwiftValidator/Rules/CardExpiryMonthRule.swift new file mode 100644 index 0000000..50ecab6 --- /dev/null +++ b/SwiftValidator/Rules/CardExpiryMonthRule.swift @@ -0,0 +1,33 @@ +// +// CardExpiryMonthRule.swift +// Validator +// +// Created by Ifeanyi Ndu on 15/01/2017. +// Copyright © 2017 jpotts18. All rights reserved. +// + +import Foundation + +public class CardExpiryMonthRule: Rule { + + private var message: String = "Must be a valid calendar month" + + public init(message : String = "Must be a valid calendar month"){ + + self.message = message + + } + + public func validate(_ value: String) -> Bool { + + guard let month = Int(value) else { + return false + } + return month >= 1 && month <= 12 + } + + public func errorMessage() -> String { + return message + } + +} diff --git a/SwiftValidator/Rules/CardExpiryYearRule.swift b/SwiftValidator/Rules/CardExpiryYearRule.swift new file mode 100644 index 0000000..30c43c4 --- /dev/null +++ b/SwiftValidator/Rules/CardExpiryYearRule.swift @@ -0,0 +1,39 @@ +// +// CardExpiryYearRule.swift +// Validator +// +// Created by Ifeanyi Ndu on 15/01/2017. +// Copyright © 2017 jpotts18. All rights reserved. +// + +import Foundation + +public class CardExpiryYearRule: Rule { + + private var message: String = "Must be within 3 years of validity" + + //change to preferred validity period + private var MAX_VALIDITY: Int = 3 + + public init(message : String = "Must be within 3 years of validity"){ + + self.message = message + + } + + public func validate(_ value: String) -> Bool { + + let thisYear = NSCalendar.current.component(Calendar.Component.year, from: Date()) + + guard let year = Int(value) else { + return false + } + + return year >= thisYear && year <= thisYear + MAX_VALIDITY + } + + public func errorMessage() -> String { + return message + } + +} diff --git a/SwiftValidator/Rules/IPV4Rule.swift b/SwiftValidator/Rules/IPV4Rule.swift index 5c024bd..3ed7948 100644 --- a/SwiftValidator/Rules/IPV4Rule.swift +++ b/SwiftValidator/Rules/IPV4Rule.swift @@ -24,4 +24,4 @@ public class IPV4Rule: RegexRule { public init(message: String = "Must be a valid IPV4 address") { super.init(regex: IPV4Rule.regex, message: message) } -} \ No newline at end of file +} diff --git a/SwiftValidatorTests/SwiftValidatorTests.swift b/SwiftValidatorTests/SwiftValidatorTests.swift index fab19bc..936cd56 100644 --- a/SwiftValidatorTests/SwiftValidatorTests.swift +++ b/SwiftValidatorTests/SwiftValidatorTests.swift @@ -31,6 +31,12 @@ class SwiftValidatorTests: XCTestCase { let VALID_FLOAT = "1234.444" let INVALID_FLOAT = "1234.44.44" + let VALID_CARD_EXPIRY_MONTH = "10" + let INVALID_CARD_EXPIRY_MONTH = "13" + + let VALID_CARD_EXPIRY_YEAR = "2018" + let INVALID_CARD_EXPIRY_YEAR = "2016" + let LEN_3 = "hey" let LEN_5 = "Howdy" let LEN_20 = "Paint the cat orange" @@ -58,6 +64,36 @@ class SwiftValidatorTests: XCTestCase { super.tearDown() } + + // MARK: Expiry Month + + func testCardExpiryMonthValid() { + XCTAssertTrue(CardExpiryMonthRule().validate(VALID_CARD_EXPIRY_MONTH), "Expiry month Should be valid") + } + + func testCardExpiryMonthInvalid() { + XCTAssertFalse(CardExpiryMonthRule().validate(INVALID_CARD_EXPIRY_MONTH), "Expiry month Should be invalid") + } + + func testCardExpiryMonthmessage() { + XCTAssertNotNil(CardExpiryMonthRule().errorMessage()) + } + + // MARK: Expiry Year + + func testCardExpiryYearValid() { + XCTAssertTrue(CardExpiryYearRule().validate(VALID_CARD_EXPIRY_YEAR), "Expiry year Should be valid") + } + + func testCardExpiryYearInvalid() { + XCTAssertFalse(CardExpiryYearRule().validate(INVALID_CARD_EXPIRY_YEAR), "Expiry year Should be invalid") + } + + func testCardExpiryYearmessage() { + XCTAssertNotNil(CardExpiryYearRule().errorMessage()) + } + + // MARK: Required func testRequired() { diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 17b420c..7062f19 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 7CC1E4D51C637C8500AF013C /* IPV4Rule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CC1E4D41C637C8500AF013C /* IPV4Rule.swift */; }; 7CC1E4D71C637F6E00AF013C /* ISBNRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CC1E4D61C637F6E00AF013C /* ISBNRule.swift */; }; 7CC1E4DB1C63BFA600AF013C /* HexColorRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CC1E4DA1C63BFA600AF013C /* HexColorRule.swift */; }; + C87F606A1E2B678B00EB8429 /* CardExpiryMonthRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87F60691E2B678B00EB8429 /* CardExpiryMonthRule.swift */; }; + C87F606C1E2B68C900EB8429 /* CardExpiryYearRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87F606B1E2B68C900EB8429 /* CardExpiryYearRule.swift */; }; FB465CB81B9884F400398388 /* SwiftValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = FB465CB71B9884F400398388 /* SwiftValidator.h */; settings = {ATTRIBUTES = (Public, ); }; }; FB465CBE1B9884F400398388 /* SwiftValidator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB465CB31B9884F400398388 /* SwiftValidator.framework */; }; FB465CC71B9884F400398388 /* SwiftValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB465CC61B9884F400398388 /* SwiftValidatorTests.swift */; }; @@ -107,6 +109,8 @@ 7CC1E4D41C637C8500AF013C /* IPV4Rule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IPV4Rule.swift; sourceTree = ""; }; 7CC1E4D61C637F6E00AF013C /* ISBNRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ISBNRule.swift; sourceTree = ""; }; 7CC1E4DA1C63BFA600AF013C /* HexColorRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HexColorRule.swift; sourceTree = ""; }; + C87F60691E2B678B00EB8429 /* CardExpiryMonthRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardExpiryMonthRule.swift; sourceTree = ""; }; + C87F606B1E2B68C900EB8429 /* CardExpiryYearRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardExpiryYearRule.swift; sourceTree = ""; }; FB465CB31B9884F400398388 /* SwiftValidator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftValidator.framework; sourceTree = BUILT_PRODUCTS_DIR; }; FB465CB61B9884F400398388 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FB465CB71B9884F400398388 /* SwiftValidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftValidator.h; sourceTree = ""; }; @@ -265,6 +269,8 @@ isa = PBXGroup; children = ( 7CC1E4CE1C636B4500AF013C /* AlphaRule.swift */, + C87F606B1E2B68C900EB8429 /* CardExpiryYearRule.swift */, + C87F60691E2B678B00EB8429 /* CardExpiryMonthRule.swift */, 7CC1E4D01C637A7700AF013C /* AlphaNumericRule.swift */, 7CC1E4D21C637ABC00AF013C /* CharacterSetRule.swift */, 7CC1E4D41C637C8500AF013C /* IPV4Rule.swift */, @@ -396,7 +402,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = jpotts18; TargetAttributes = { 62D1AE161A1E6D4400E4DFF8 = { @@ -405,7 +411,7 @@ }; 62D1AE2B1A1E6D4500E4DFF8 = { CreatedOnToolsVersion = 6.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0820; TestTargetID = 62D1AE161A1E6D4400E4DFF8; }; FB465CB21B9884F400398388 = { @@ -505,9 +511,11 @@ FB465CFD1B9889EA00398388 /* Rule.swift in Sources */, FB465CFA1B9889EA00398388 /* PhoneNumberRule.swift in Sources */, FB465CF51B9889EA00398388 /* FloatRule.swift in Sources */, + C87F606C1E2B68C900EB8429 /* CardExpiryYearRule.swift in Sources */, 7CC1E4DB1C63BFA600AF013C /* HexColorRule.swift in Sources */, FB465D011B9889EA00398388 /* Validator.swift in Sources */, FB465CFE1B9889EA00398388 /* ValidationRule.swift in Sources */, + C87F606A1E2B678B00EB8429 /* CardExpiryMonthRule.swift in Sources */, FB465CF31B9889EA00398388 /* ConfirmRule.swift in Sources */, FB51E5B01CD208B8004DE696 /* Validatable.swift in Sources */, 7CC1E4D51C637C8500AF013C /* IPV4Rule.swift in Sources */, @@ -656,6 +664,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -664,6 +673,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Validator/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; @@ -676,6 +686,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Validator/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; @@ -689,6 +700,7 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -697,6 +709,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; @@ -706,6 +719,7 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = ValidatorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; @@ -718,6 +732,7 @@ FB465CCC1B9884F400398388 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; @@ -745,6 +760,7 @@ FB465CCD1B9884F400398388 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; diff --git a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme index b8b0c59..825d974 100644 --- a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme +++ b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme @@ -1,6 +1,6 @@ Date: Sun, 15 Jan 2017 09:12:20 +0000 Subject: [PATCH 13/29] Added comments and fixed some typos --- .../Rules/CardExpiryMonthRule.swift | 25 ++++++++++++++--- SwiftValidator/Rules/CardExpiryYearRule.swift | 28 ++++++++++++++++--- SwiftValidator/Rules/RequiredRule.swift | 2 +- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/SwiftValidator/Rules/CardExpiryMonthRule.swift b/SwiftValidator/Rules/CardExpiryMonthRule.swift index 50ecab6..3091544 100644 --- a/SwiftValidator/Rules/CardExpiryMonthRule.swift +++ b/SwiftValidator/Rules/CardExpiryMonthRule.swift @@ -8,16 +8,28 @@ import Foundation +/** + `CardExpiryMonthRule` is a subclass of `Rule` that defines how a credit/debit's card expiry month field is validated + */ public class CardExpiryMonthRule: Rule { - + /// Error message to be displayed if validation fails. private var message: String = "Must be a valid calendar month" - + /** + Initializes `CardExpiryMonthRule` object with error message. Used to validate a card's expiry month. + + - parameter message: String of error message. + - returns: An initialized `CardExpiryMonthRule` object, or nil if an object could not be created for some reason that would not result in an exception. + */ public init(message : String = "Must be a valid calendar month"){ - self.message = message - } + /** + Validates a field. + + - parameter value: String to check for validation. + - returns: Boolean value. True on successful validation, otherwise False on failed Validation. + */ public func validate(_ value: String) -> Bool { guard let month = Int(value) else { @@ -26,6 +38,11 @@ public class CardExpiryMonthRule: Rule { return month >= 1 && month <= 12 } + /** + Used to display error message when validation fails. + + - returns: String of error message. + */ public func errorMessage() -> String { return message } diff --git a/SwiftValidator/Rules/CardExpiryYearRule.swift b/SwiftValidator/Rules/CardExpiryYearRule.swift index 30c43c4..c02eab7 100644 --- a/SwiftValidator/Rules/CardExpiryYearRule.swift +++ b/SwiftValidator/Rules/CardExpiryYearRule.swift @@ -8,30 +8,50 @@ import Foundation +/** + `CardExpiryYearRule` is a subclass of `Rule` that defines how a credit/debit's card expiry year field is validated + */ public class CardExpiryYearRule: Rule { - + /// Error message to be displayed if validation fails. private var message: String = "Must be within 3 years of validity" - - //change to preferred validity period + ///Default maximum validity period. Change to preferred value private var MAX_VALIDITY: Int = 3 + /** + Initializes `CardExpiryYearRule` object with error message. Used to validate a card's expiry year. + + - parameter message: String of error message. + - returns: An initialized `CardExpiryYearRule` object, or nil if an object could not be created for some reason that would not result in an exception. + */ public init(message : String = "Must be within 3 years of validity"){ self.message = message } + /** + Validates a field. + + - parameter value: String to check for validation. + - returns: Boolean value. True on successful validation, otherwise False on failed Validation. + */ public func validate(_ value: String) -> Bool { + ///Holds the current year let thisYear = NSCalendar.current.component(Calendar.Component.year, from: Date()) guard let year = Int(value) else { return false } - return year >= thisYear && year <= thisYear + MAX_VALIDITY + return year >= thisYear && year <= (thisYear + MAX_VALIDITY) } + /** + Used to display error message when validation fails. + + - returns: String of error message. + */ public func errorMessage() -> String { return message } diff --git a/SwiftValidator/Rules/RequiredRule.swift b/SwiftValidator/Rules/RequiredRule.swift index ace8ee5..dba58a3 100644 --- a/SwiftValidator/Rules/RequiredRule.swift +++ b/SwiftValidator/Rules/RequiredRule.swift @@ -28,7 +28,7 @@ public class RequiredRule: Rule { /** Validates a field. - - parameter value: String to checked for validation. + - parameter value: String to check for validation. - returns: Boolean value. True if validation is successful; False if validation fails. */ public func validate(_ value: String) -> Bool { From d89d18b0190df5ae5026cc4dc71b9fecd27ff344 Mon Sep 17 00:00:00 2001 From: Asia Date: Fri, 2 Jun 2017 15:35:07 +0200 Subject: [PATCH 14/29] Update README.md Fixed bug with ZipCodeRule (: for the place of =) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1df8d96..f1ecc85 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ override func viewDidLoad() { // You can now pass in regex and length parameters through overloaded contructors validator.registerField(phoneNumberTextField, errorLabel: phoneNumberErrorLabel, rules: [RequiredRule(), MinLengthRule(length: 9)]) - validator.registerField(zipcodeTextField, errorLabel: zipcodeErrorLabel, rules: [RequiredRule(), ZipCodeRule(regex = "\\d{5}")]) + validator.registerField(zipcodeTextField, errorLabel: zipcodeErrorLabel, rules: [RequiredRule(), ZipCodeRule(regex : "\\d{5}")]) // You can unregister a text field if you no longer want to validate it validator.unregisterField(fullNameTextField) From 0debc5d7ebe1f66f7c99e61fafa5ffb207ca3ebd Mon Sep 17 00:00:00 2001 From: Johannes Pfeiffer Date: Fri, 29 Sep 2017 19:06:44 +0200 Subject: [PATCH 15/29] Update README.md Updated installation snippet to swift 4 --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f1ecc85..8cacd3b 100644 --- a/README.md +++ b/README.md @@ -107,16 +107,16 @@ func validationSuccessful() { // submit the form } -func validationFailed(errors:[(Validatable ,ValidationError)]) { - // turn the fields to red - for (field, error) in errors { - if let field = field as? UITextField { - field.layer.borderColor = UIColor.redColor().CGColor - field.layer.borderWidth = 1.0 - } - error.errorLabel?.text = error.errorMessage // works if you added labels - error.errorLabel?.hidden = false - } +func validationFailed(_ errors:[(Validatable ,ValidationError)]) { + // turn the fields to red + for (field, error) in errors { + if let field = field as? UITextField { + field.layer.borderColor = UIColor.red.cgColor + field.layer.borderWidth = 1.0 + } + error.errorLabel?.text = error.errorMessage // works if you added labels + error.errorLabel?.isHidden = false + } } ``` From 55797b4dc8ae63164d20a4c28c2413786b492167 Mon Sep 17 00:00:00 2001 From: Ilker Ozcan Date: Thu, 4 Jan 2018 15:07:45 +0300 Subject: [PATCH 16/29] Updated UITextField Validatable extension. --- SwiftValidator/Core/Validatable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftValidator/Core/Validatable.swift b/SwiftValidator/Core/Validatable.swift index 3ca537e..a5baf0f 100644 --- a/SwiftValidator/Core/Validatable.swift +++ b/SwiftValidator/Core/Validatable.swift @@ -19,7 +19,7 @@ public protocol Validatable { extension UITextField: Validatable { - public var validationText: String { + open var validationText: String { return text ?? "" } } From b3f8d74212f290077848b2783692976e5e1b6957 Mon Sep 17 00:00:00 2001 From: Deepak Badiger Date: Thu, 19 Apr 2018 14:11:24 -0400 Subject: [PATCH 17/29] Enabled Swift 4.1 --- SwiftValidator/Rules/ExactLengthRule.swift | 2 +- SwiftValidator/Rules/FloatRule.swift | 2 +- SwiftValidator/Rules/FullNameRule.swift | 2 +- SwiftValidator/Rules/ISBNRule.swift | 12 +++--- SwiftValidator/Rules/MaxLengthRule.swift | 2 +- SwiftValidator/Rules/MinLengthRule.swift | 2 +- Validator.xcodeproj/project.pbxproj | 39 ++++++++++++++----- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ .../xcschemes/SwiftValidator.xcscheme | 2 +- .../xcschemes/SwiftValidatorTests.xcscheme | 6 +-- .../xcshareddata/xcschemes/Validator.xcscheme | 2 +- Validator/ViewController.swift | 2 +- 12 files changed, 55 insertions(+), 26 deletions(-) create mode 100644 Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/SwiftValidator/Rules/ExactLengthRule.swift b/SwiftValidator/Rules/ExactLengthRule.swift index c9aae6d..4798bd9 100644 --- a/SwiftValidator/Rules/ExactLengthRule.swift +++ b/SwiftValidator/Rules/ExactLengthRule.swift @@ -36,7 +36,7 @@ public class ExactLengthRule : Rule { - returns: A boolean value. True if validation is successful; False if validation fails. */ public func validate(_ value: String) -> Bool { - return value.characters.count == length + return value.count == length } /** diff --git a/SwiftValidator/Rules/FloatRule.swift b/SwiftValidator/Rules/FloatRule.swift index cf30557..669c0e0 100644 --- a/SwiftValidator/Rules/FloatRule.swift +++ b/SwiftValidator/Rules/FloatRule.swift @@ -34,7 +34,7 @@ public class FloatRule:Rule { public func validate(_ value: String) -> Bool { let regex = try? NSRegularExpression(pattern: "^[-+]?(\\d*[.])?\\d+$", options: []) if let regex = regex { - let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.characters.count)) + let match = regex.numberOfMatches(in: value, options: [], range: NSRange(location: 0, length: value.count)) return match == 1 } return false diff --git a/SwiftValidator/Rules/FullNameRule.swift b/SwiftValidator/Rules/FullNameRule.swift index b9894e0..de94c49 100644 --- a/SwiftValidator/Rules/FullNameRule.swift +++ b/SwiftValidator/Rules/FullNameRule.swift @@ -31,7 +31,7 @@ public class FullNameRule : Rule { - returns: A boolean value. True if validation is successful; False if validation fails. */ public func validate(_ value: String) -> Bool { - let nameArray: [String] = value.characters.split { $0 == " " }.map { String($0) } + let nameArray: [String] = value.split { $0 == " " }.map { String($0) } return nameArray.count >= 2 } diff --git a/SwiftValidator/Rules/ISBNRule.swift b/SwiftValidator/Rules/ISBNRule.swift index 6f8654f..4d39b0e 100644 --- a/SwiftValidator/Rules/ISBNRule.swift +++ b/SwiftValidator/Rules/ISBNRule.swift @@ -38,7 +38,7 @@ public class ISBNRule: Rule { fatalError("Invalid ISBN sanitizing regex") } - let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.characters.count), withTemplate: "") + let sanitized = regex.stringByReplacingMatches(in: value, options: [], range: NSMakeRange(0, value.count), withTemplate: "") return ISBN10Validator().verify(sanitized) || ISBN13Validator().verify(sanitized) } @@ -140,15 +140,15 @@ private struct ISBN10Validator: ISBNValidator { var checksum = 0 for i in 0..<9 { - if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) { + if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: i)])) { checksum += (i + 1) * intCharacter } } - if (input[input.characters.index(input.startIndex, offsetBy: 9)] == "X") { + if (input[input.index(input.startIndex, offsetBy: 9)] == "X") { checksum += 10 * 10 } else { - if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: 9)])) { + if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: 9)])) { checksum += 10 * intCharacter } } @@ -176,13 +176,13 @@ private struct ISBN13Validator: ISBNValidator { var checksum = 0 for i in 0..<12 { - if let intCharacter = Int(String(input[input.characters.index(input.startIndex, offsetBy: i)])) { + if let intCharacter = Int(String(input[input.index(input.startIndex, offsetBy: i)])) { print("\(factor[i%2]) * \(intCharacter)") checksum += factor[i % 2] * intCharacter } } - if let lastInt = Int(String(input[input.characters.index(input.startIndex, offsetBy: 12)])) { + if let lastInt = Int(String(input[input.index(input.startIndex, offsetBy: 12)])) { return (lastInt - ((10 - (checksum % 10)) % 10) == 0) } diff --git a/SwiftValidator/Rules/MaxLengthRule.swift b/SwiftValidator/Rules/MaxLengthRule.swift index 57d9b7b..0c65d81 100644 --- a/SwiftValidator/Rules/MaxLengthRule.swift +++ b/SwiftValidator/Rules/MaxLengthRule.swift @@ -37,7 +37,7 @@ public class MaxLengthRule: Rule { - returns: A boolean value. True if validation is successful; False if validation fails. */ public func validate(_ value: String) -> Bool { - return value.characters.count <= DEFAULT_LENGTH + return value.count <= DEFAULT_LENGTH } /** diff --git a/SwiftValidator/Rules/MinLengthRule.swift b/SwiftValidator/Rules/MinLengthRule.swift index d9e161c..b83166d 100644 --- a/SwiftValidator/Rules/MinLengthRule.swift +++ b/SwiftValidator/Rules/MinLengthRule.swift @@ -38,7 +38,7 @@ public class MinLengthRule: Rule { - returns: A boolean value. True if validation is successful; False if validation fails. */ public func validate(_ value: String) -> Bool { - return value.characters.count >= DEFAULT_LENGTH + return value.count >= DEFAULT_LENGTH } /** diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 17b420c..e0ff2e2 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -396,7 +396,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = jpotts18; TargetAttributes = { 62D1AE161A1E6D4400E4DFF8 = { @@ -584,14 +584,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -619,6 +627,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -630,14 +639,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -656,6 +673,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -668,7 +687,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -681,7 +700,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -697,7 +716,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.1; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -710,7 +729,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.1; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; @@ -718,6 +737,7 @@ FB465CCC1B9884F400398388 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; @@ -735,7 +755,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -745,6 +765,7 @@ FB465CCD1B9884F400398388 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -760,7 +781,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -785,7 +806,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -806,7 +827,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; diff --git a/Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Validator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme index b8b0c59..d6ae464 100644 --- a/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme +++ b/Validator.xcodeproj/xcshareddata/xcschemes/SwiftValidator.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme b/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme index e9d5ba4..5da1196 100644 --- a/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme +++ b/Validator.xcodeproj/xcshareddata/xcschemes/Validator.xcscheme @@ -1,6 +1,6 @@ Date: Sun, 22 Apr 2018 22:35:22 -0600 Subject: [PATCH 18/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1ecc85..90d7f64 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ class SSNVRule: RegexRule { ``` ## Documentation -Checkout the docs here via [@jazzydocs](https://twitter.com/jazzydocs). +Checkout the docs here via [@jazzydocs](https://twitter.com/jazzydocs). Credits From bef1c1802a811d4829d3e13cf2cfeffbdcecb3bf Mon Sep 17 00:00:00 2001 From: Jeff Potter Date: Sun, 22 Apr 2018 23:20:02 -0600 Subject: [PATCH 19/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90d7f64..f489c07 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ SwiftValidator =============== -[![Build Status](https://travis-ci.org/jpotts18/SwiftValidator.svg?branch=travis-ci)](https://travis-ci.org/jpotts18/SwiftValidator) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![codecov.io](https://codecov.io/github/jpotts18/SwiftValidator/coverage.svg?branch=master)](https://codecov.io/github/jpotts18/SwiftValidator?branch=master) +[![Build Status](https://travis-ci.org/SwiftValidatorCommunity/SwiftValidator.svg?branch=master)](https://travis-ci.org/SwiftValidatorCommunity/SwiftValidator) [![codecov.io](https://codecov.io/github/SwiftValidatorCommunity/SwiftValidator/coverage.svg?branch=master)](https://codecov.io/github/SwiftValidatorCommunity/SwiftValidator?branch=master) Swift Validator is a rule-based validation library for Swift. From fb50b9788864378336830477a174c2501b19df84 Mon Sep 17 00:00:00 2001 From: Jeff Potter Date: Sun, 22 Apr 2018 23:30:12 -0600 Subject: [PATCH 20/29] Update .travis.yml --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 761d5a8..47d6e33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,12 @@ script: - pod lib lint after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) + + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/4cfa929bd227586305cc + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always From eb2f694ea2de9b64f4a8942ae64fa9ec9490456f Mon Sep 17 00:00:00 2001 From: Rajat jain <10336073+RajatJain4061@users.noreply.github.com> Date: Fri, 8 Mar 2019 11:54:56 +0530 Subject: [PATCH 21/29] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47d6e33..46ffccd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8 +osx_image: xcode10.1 xcode_sdk: iphonesimulator10.0 xcode_project: Validator.xcodeproj xcode_scheme: Validator From 7117ce60a78f64ce8d966385efdb8b099628452d Mon Sep 17 00:00:00 2001 From: Rajat jain <10336073+RajatJain4061@users.noreply.github.com> Date: Fri, 8 Mar 2019 12:08:36 +0530 Subject: [PATCH 22/29] Update SwiftValidator.podspec --- SwiftValidator.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SwiftValidator.podspec b/SwiftValidator.podspec index 5a15ee4..fdcaa3c 100644 --- a/SwiftValidator.podspec +++ b/SwiftValidator.podspec @@ -1,6 +1,7 @@ Pod::Spec.new do |s| s.name = "SwiftValidator" - s.version = "4.0.0" + s.version = "4.2.0" + s.swift_version = "4.2" 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" From d2c06fa0e9428199233f31ab243057e17554af71 Mon Sep 17 00:00:00 2001 From: Rajat jain <10336073+RajatJain4061@users.noreply.github.com> Date: Fri, 8 Mar 2019 12:16:01 +0530 Subject: [PATCH 23/29] Update SwiftValidator.podspec --- SwiftValidator.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftValidator.podspec b/SwiftValidator.podspec index fdcaa3c..e426329 100644 --- a/SwiftValidator.podspec +++ b/SwiftValidator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SwiftValidator" - s.version = "4.2.0" + s.version = "4.0.0" s.swift_version = "4.2" s.summary = "A UITextField Validation library for Swift" s.homepage = "https://github.com/jpotts18/SwiftValidator" From d414e1505c2834b02d8754fc36f8a4941cce7847 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Fri, 8 Mar 2019 06:58:08 +0000 Subject: [PATCH 24/29] Upgrade to Swift 4.2 (#212) * Upgrade to Swift 4.2 --- Validator.xcodeproj/project.pbxproj | 12 ++---------- Validator/AppDelegate.swift | 28 +--------------------------- Validator/ViewController.swift | 2 +- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index e0ff2e2..ec0c4c7 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -627,7 +627,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -674,7 +674,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VALIDATE_PRODUCT = YES; }; name = Release; @@ -687,7 +687,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -700,7 +699,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; }; name = Release; }; @@ -716,7 +714,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.1; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -729,7 +726,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.1; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; @@ -755,7 +751,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -781,7 +776,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -806,7 +800,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -827,7 +820,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; diff --git a/Validator/AppDelegate.swift b/Validator/AppDelegate.swift index a68462f..598ba7a 100644 --- a/Validator/AppDelegate.swift +++ b/Validator/AppDelegate.swift @@ -13,34 +13,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } - - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - } diff --git a/Validator/ViewController.swift b/Validator/ViewController.swift index 5fc9871..786b071 100644 --- a/Validator/ViewController.swift +++ b/Validator/ViewController.swift @@ -69,7 +69,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate func validationSuccessful() { print("Validation Success!") - let alert = UIAlertController(title: "Success", message: "You are validated!", preferredStyle: UIAlertControllerStyle.alert) + let alert = UIAlertController(title: "Success", message: "You are validated!", preferredStyle: UIAlertController.Style.alert) let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil) alert.addAction(defaultAction) self.present(alert, animated: true, completion: nil) From 230583e0e34649501dbb8772124d196eb49bfd82 Mon Sep 17 00:00:00 2001 From: Rajat jain <10336073+RajatJain4061@users.noreply.github.com> Date: Fri, 8 Mar 2019 15:03:19 +0530 Subject: [PATCH 25/29] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ec56037..79e3c7b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ platform :ios, "8.1" use_frameworks! +# Swift 4.2 +pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :tag => '4.2.0' + # Swift 3 # Extended beyond UITextField pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :branch => 'master' From 59e7ca017dfd760ba36584dd3ac132d5eb530d88 Mon Sep 17 00:00:00 2001 From: Albert Arredondo Date: Wed, 27 Mar 2019 18:26:43 +0100 Subject: [PATCH 26/29] Migrate to Swift 5.0 --- Validator.xcodeproj/project.pbxproj | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index fb03e8a..978d1bb 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -407,7 +407,7 @@ TargetAttributes = { 62D1AE161A1E6D4400E4DFF8 = { CreatedOnToolsVersion = 6.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; }; 62D1AE2B1A1E6D4500E4DFF8 = { CreatedOnToolsVersion = 6.1; @@ -416,18 +416,18 @@ }; FB465CB21B9884F400398388 = { CreatedOnToolsVersion = 6.4; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; }; FB465CBC1B9884F400398388 = { CreatedOnToolsVersion = 6.4; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; TestTargetID = 62D1AE161A1E6D4400E4DFF8; }; }; }; buildConfigurationList = 62D1AE121A1E6D4400E4DFF8 /* Build configuration list for PBXProject "Validator" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -696,6 +696,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -709,6 +710,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -763,6 +765,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jeffpotter.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -788,6 +791,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -812,6 +816,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Debug; @@ -832,6 +837,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.levous.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Validator.app/Validator"; }; name = Release; From 245175bc693c76114415bc0b82e48bb5c5659806 Mon Sep 17 00:00:00 2001 From: Albert Arredondo Date: Mon, 15 Apr 2019 16:59:42 +0200 Subject: [PATCH 27/29] Remove Validator Application from Project targets. --- Validator.xcodeproj/project.pbxproj | 148 ---------------------------- 1 file changed, 148 deletions(-) diff --git a/Validator.xcodeproj/project.pbxproj b/Validator.xcodeproj/project.pbxproj index 978d1bb..b160122 100644 --- a/Validator.xcodeproj/project.pbxproj +++ b/Validator.xcodeproj/project.pbxproj @@ -8,10 +8,6 @@ /* Begin PBXBuildFile section */ 62C1821D1C6312F5003788E7 /* ExactLengthRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62C1821C1C6312F5003788E7 /* ExactLengthRule.swift */; }; - 62D1AE1D1A1E6D4400E4DFF8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D1AE1C1A1E6D4400E4DFF8 /* AppDelegate.swift */; }; - 62D1AE221A1E6D4400E4DFF8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 62D1AE201A1E6D4400E4DFF8 /* Main.storyboard */; }; - 62D1AE241A1E6D4400E4DFF8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 62D1AE231A1E6D4400E4DFF8 /* Images.xcassets */; }; - 62D1AE271A1E6D4400E4DFF8 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 62D1AE251A1E6D4400E4DFF8 /* LaunchScreen.xib */; }; 62D9B2561C7C0B2A00BAFCE3 /* ValidationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D9B2551C7C0B2A00BAFCE3 /* ValidationDelegate.swift */; }; 7CC1E4CF1C636B4500AF013C /* AlphaRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CC1E4CE1C636B4500AF013C /* AlphaRule.swift */; }; 7CC1E4D11C637A7700AF013C /* AlphaNumericRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CC1E4D01C637A7700AF013C /* AlphaNumericRule.swift */; }; @@ -24,9 +20,6 @@ FB465CB81B9884F400398388 /* SwiftValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = FB465CB71B9884F400398388 /* SwiftValidator.h */; settings = {ATTRIBUTES = (Public, ); }; }; FB465CBE1B9884F400398388 /* SwiftValidator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB465CB31B9884F400398388 /* SwiftValidator.framework */; }; FB465CC71B9884F400398388 /* SwiftValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB465CC61B9884F400398388 /* SwiftValidatorTests.swift */; }; - FB465CCA1B9884F400398388 /* SwiftValidator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB465CB31B9884F400398388 /* SwiftValidator.framework */; }; - FB465CCB1B9884F400398388 /* SwiftValidator.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FB465CB31B9884F400398388 /* SwiftValidator.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - FB465CE11B98854100398388 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D1AE1E1A1E6D4400E4DFF8 /* ViewController.swift */; }; FB465CF31B9889EA00398388 /* ConfirmRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB465CE31B9889EA00398388 /* ConfirmRule.swift */; }; FB465CF41B9889EA00398388 /* EmailRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB465CE41B9889EA00398388 /* EmailRule.swift */; }; FB465CF51B9889EA00398388 /* FloatRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB465CE51B9889EA00398388 /* FloatRule.swift */; }; @@ -47,13 +40,6 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 62D1AE2D1A1E6D4500E4DFF8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 62D1AE0F1A1E6D4400E4DFF8 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 62D1AE161A1E6D4400E4DFF8; - remoteInfo = Validator; - }; FB465CBF1B9884F400398388 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 62D1AE0F1A1E6D4400E4DFF8 /* Project object */; @@ -61,39 +47,10 @@ remoteGlobalIDString = FB465CB21B9884F400398388; remoteInfo = SwiftValidator; }; - FB465CC11B9884F400398388 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 62D1AE0F1A1E6D4400E4DFF8 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 62D1AE161A1E6D4400E4DFF8; - remoteInfo = Validator; - }; - FB465CC81B9884F400398388 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 62D1AE0F1A1E6D4400E4DFF8 /* Project object */; - proxyType = 1; - remoteGlobalIDString = FB465CB21B9884F400398388; - remoteInfo = SwiftValidator; - }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - FB465CD11B9884F400398388 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - FB465CCB1B9884F400398388 /* SwiftValidator.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 62C1821C1C6312F5003788E7 /* ExactLengthRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExactLengthRule.swift; sourceTree = ""; }; - 62D1AE171A1E6D4400E4DFF8 /* Validator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Validator.app; sourceTree = BUILT_PRODUCTS_DIR; }; 62D1AE1B1A1E6D4400E4DFF8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62D1AE1C1A1E6D4400E4DFF8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 62D1AE1E1A1E6D4400E4DFF8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -137,14 +94,6 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 62D1AE141A1E6D4400E4DFF8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - FB465CCA1B9884F400398388 /* SwiftValidator.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 62D1AE291A1E6D4500E4DFF8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -184,7 +133,6 @@ 62D1AE181A1E6D4400E4DFF8 /* Products */ = { isa = PBXGroup; children = ( - 62D1AE171A1E6D4400E4DFF8 /* Validator.app */, 62D1AE2C1A1E6D4500E4DFF8 /* ValidatorTests.xctest */, FB465CB31B9884F400398388 /* SwiftValidator.framework */, FB465CBD1B9884F400398388 /* SwiftValidatorTests.xctest */, @@ -320,25 +268,6 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 62D1AE161A1E6D4400E4DFF8 /* Validator */ = { - isa = PBXNativeTarget; - buildConfigurationList = 62D1AE361A1E6D4500E4DFF8 /* Build configuration list for PBXNativeTarget "Validator" */; - buildPhases = ( - 62D1AE131A1E6D4400E4DFF8 /* Sources */, - 62D1AE141A1E6D4400E4DFF8 /* Frameworks */, - 62D1AE151A1E6D4400E4DFF8 /* Resources */, - FB465CD11B9884F400398388 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - FB465CC91B9884F400398388 /* PBXTargetDependency */, - ); - name = Validator; - productName = Validator; - productReference = 62D1AE171A1E6D4400E4DFF8 /* Validator.app */; - productType = "com.apple.product-type.application"; - }; 62D1AE2B1A1E6D4500E4DFF8 /* ValidatorTests */ = { isa = PBXNativeTarget; buildConfigurationList = 62D1AE391A1E6D4500E4DFF8 /* Build configuration list for PBXNativeTarget "ValidatorTests" */; @@ -350,7 +279,6 @@ buildRules = ( ); dependencies = ( - 62D1AE2E1A1E6D4500E4DFF8 /* PBXTargetDependency */, ); name = ValidatorTests; productName = ValidatorTests; @@ -387,7 +315,6 @@ ); dependencies = ( FB465CC01B9884F400398388 /* PBXTargetDependency */, - FB465CC21B9884F400398388 /* PBXTargetDependency */, ); name = SwiftValidatorTests; productName = SwiftValidatorTests; @@ -405,10 +332,6 @@ LastUpgradeCheck = 0930; ORGANIZATIONNAME = jpotts18; TargetAttributes = { - 62D1AE161A1E6D4400E4DFF8 = { - CreatedOnToolsVersion = 6.1; - LastSwiftMigration = 1020; - }; 62D1AE2B1A1E6D4500E4DFF8 = { CreatedOnToolsVersion = 6.1; LastSwiftMigration = 0820; @@ -438,7 +361,6 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 62D1AE161A1E6D4400E4DFF8 /* Validator */, 62D1AE2B1A1E6D4500E4DFF8 /* ValidatorTests */, FB465CB21B9884F400398388 /* SwiftValidator */, FB465CBC1B9884F400398388 /* SwiftValidatorTests */, @@ -447,16 +369,6 @@ /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 62D1AE151A1E6D4400E4DFF8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 62D1AE221A1E6D4400E4DFF8 /* Main.storyboard in Resources */, - 62D1AE271A1E6D4400E4DFF8 /* LaunchScreen.xib in Resources */, - 62D1AE241A1E6D4400E4DFF8 /* Images.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 62D1AE2A1A1E6D4500E4DFF8 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -481,15 +393,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 62D1AE131A1E6D4400E4DFF8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - FB465CE11B98854100398388 /* ViewController.swift in Sources */, - 62D1AE1D1A1E6D4400E4DFF8 /* AppDelegate.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 62D1AE281A1E6D4500E4DFF8 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -542,26 +445,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 62D1AE2E1A1E6D4500E4DFF8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 62D1AE161A1E6D4400E4DFF8 /* Validator */; - targetProxy = 62D1AE2D1A1E6D4500E4DFF8 /* PBXContainerItemProxy */; - }; FB465CC01B9884F400398388 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = FB465CB21B9884F400398388 /* SwiftValidator */; targetProxy = FB465CBF1B9884F400398388 /* PBXContainerItemProxy */; }; - FB465CC21B9884F400398388 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 62D1AE161A1E6D4400E4DFF8 /* Validator */; - targetProxy = FB465CC11B9884F400398388 /* PBXContainerItemProxy */; - }; - FB465CC91B9884F400398388 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = FB465CB21B9884F400398388 /* SwiftValidator */; - targetProxy = FB465CC81B9884F400398388 /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -687,33 +575,6 @@ }; name = Release; }; - 62D1AE371A1E6D4500E4DFF8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; - 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)"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 62D1AE381A1E6D4500E4DFF8 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; - 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)"; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; 62D1AE3A1A1E6D4500E4DFF8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -854,15 +715,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 62D1AE361A1E6D4500E4DFF8 /* Build configuration list for PBXNativeTarget "Validator" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 62D1AE371A1E6D4500E4DFF8 /* Debug */, - 62D1AE381A1E6D4500E4DFF8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 62D1AE391A1E6D4500E4DFF8 /* Build configuration list for PBXNativeTarget "ValidatorTests" */ = { isa = XCConfigurationList; buildConfigurations = ( From 0f6e19f28e857854a885570b319a19025c430c91 Mon Sep 17 00:00:00 2001 From: Albert Arredondo Date: Mon, 15 Apr 2019 17:22:01 +0200 Subject: [PATCH 28/29] Update osx_image to xCode10.2.- --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 46ffccd..3da032e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10.1 +osx_image: xcode10.2 xcode_sdk: iphonesimulator10.0 xcode_project: Validator.xcodeproj xcode_scheme: Validator From 06a95da3bf877e639544d77eb2f8527ad1753661 Mon Sep 17 00:00:00 2001 From: Albert Arredondo Date: Wed, 17 Apr 2019 09:21:17 +0200 Subject: [PATCH 29/29] Revert "Update osx_image to xCode10.2.-" This reverts commit 0f6e19f28e857854a885570b319a19025c430c91. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3da032e..46ffccd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10.2 +osx_image: xcode10.1 xcode_sdk: iphonesimulator10.0 xcode_project: Validator.xcodeproj xcode_scheme: Validator