From 2c88a2550a3373a17ce5e768860c55a17878e293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 15:53:49 -0200 Subject: [PATCH 1/9] added Brazilian Cards --- Example/SwiftLuhn.xcodeproj/project.pbxproj | 2 +- SwiftLuhn/Classes/SwiftLuhn.swift | 27 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Example/SwiftLuhn.xcodeproj/project.pbxproj b/Example/SwiftLuhn.xcodeproj/project.pbxproj index 3472abe..4b9f8c9 100644 --- a/Example/SwiftLuhn.xcodeproj/project.pbxproj +++ b/Example/SwiftLuhn.xcodeproj/project.pbxproj @@ -49,7 +49,7 @@ A2BCD9AE2D95C7DCB60CB392 /* Pods-SwiftLuhn_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftLuhn_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftLuhn_Example/Pods-SwiftLuhn_Example.release.xcconfig"; sourceTree = ""; }; AA640ED277322E98AADE4DB9 /* Pods-SwiftLuhn_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftLuhn_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftLuhn_Tests/Pods-SwiftLuhn_Tests.debug.xcconfig"; sourceTree = ""; }; B2FBF89F16A4DC0F2751FEC7 /* Pods-SwiftLuhn_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftLuhn_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftLuhn_Example/Pods-SwiftLuhn_Example.debug.xcconfig"; sourceTree = ""; }; - B90E7FE8BD11978D5BB1B434 /* SwiftLuhn.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SwiftLuhn.podspec; path = ../SwiftLuhn.podspec; sourceTree = ""; }; + B90E7FE8BD11978D5BB1B434 /* SwiftLuhn.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SwiftLuhn.podspec; path = ../SwiftLuhn.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; CC106E6E669DC2ACEADFF7AC /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; /* End PBXFileReference section */ diff --git a/SwiftLuhn/Classes/SwiftLuhn.swift b/SwiftLuhn/Classes/SwiftLuhn.swift index 3495f8a..c9298d4 100644 --- a/SwiftLuhn/Classes/SwiftLuhn.swift +++ b/SwiftLuhn/Classes/SwiftLuhn.swift @@ -19,6 +19,9 @@ open class SwiftLuhn { case maestro case rupay case mir + case elo + case hiperCard + case aura } public enum CardError: Error { @@ -46,6 +49,12 @@ open class SwiftLuhn { return "^6[0-9]{15}$" case .mir: return "^220[0-9]{13}$" + case .elo: + return "^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|50(9[0-9][0-9][0-9])|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|05([7-9])|06([0-9])|07([0-9])|08([0-9])|4([0-3][0-9]|8[5-9]|9[0-9])|5([0-9][0-9]|3[0-8])|9([0-6][0-9]|7[0-8])|7([0-2][0-9])|541|700|720|727|901)|65165([2-9])|6516([6-7][0-9])|65500([0-9])|6550([0-5][0-9])|655021|65505([6-7])|6516([8-9][0-9])|65170([0-4]))" + case .hiperCard: + return "^(((637095)|(637612)|(637599)|(637609)|(637568))\d{0,10})$" + case .aura: + return "^50[0-9]{14,17}$" } } @@ -69,6 +78,12 @@ open class SwiftLuhn { return "^6[0-9]+$" case .mir: return "^220[0-9]+$" + case .elo: + return "^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|50(9[0-9][0-9][0-9])|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|05([7-9])|06([0-9])|07([0-9])|08([0-9])|4([0-3][0-9]|8[5-9]|9[0-9])|5([0-9][0-9]|3[0-8])|9([0-6][0-9]|7[0-8])|7([0-2][0-9])|541|700|720|727|901)|65165([2-9])|6516([6-7][0-9])|65500([0-9])|6550([0-5][0-9])|655021|65505([6-7])|6516([8-9][0-9])|65170([0-4]))" + case .hiperCard: + return "^(((637095)|(637612)|(637599)|(637609)|(637568))\d{0,10})$" + case .aura: + return "^50[0-9]{14,17}$" } } @@ -157,6 +172,12 @@ public extension SwiftLuhn.CardType { return "Rupay" case .mir: return "Mir" + case .elo: + return "Elo" + case .hiperCard: + return "HiperCard" + case .aura: + return "Aura" } } @@ -180,6 +201,12 @@ public extension SwiftLuhn.CardType { self.init(rawValue: 7) case "mir": self.init(rawValue: 8) + case "elo": + self.init(rawValue: 9) + case "hipercard": + self.init(rawValue: 10) + case "aura": + self.init(rawValue: 11) default: return nil } From 18a74088f30c3462c1f2954cf8b05d196af47e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 15:56:03 -0200 Subject: [PATCH 2/9] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 58d0ddc..84e0764 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ You can also get the type of the card being used which will be one of: |Discover| |Diner's Club| |JCB| +|Elo| +|HiperCard| +|Aura| ```swift do { From 55fc62ab7f5075baa017865c72790b6b0d30c39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:08:37 -0200 Subject: [PATCH 3/9] Update Regex, Readme and podspect --- Example/SwiftLuhn.xcodeproj/project.pbxproj | 6 ++++++ README.md | 3 ++- SwiftLuhn.podspec | 2 +- SwiftLuhn/Classes/SwiftLuhn.swift | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Example/SwiftLuhn.xcodeproj/project.pbxproj b/Example/SwiftLuhn.xcodeproj/project.pbxproj index 4b9f8c9..6f41f54 100644 --- a/Example/SwiftLuhn.xcodeproj/project.pbxproj +++ b/Example/SwiftLuhn.xcodeproj/project.pbxproj @@ -218,10 +218,12 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = X4EYDGL7NV; LastSwiftMigration = 0940; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = X4EYDGL7NV; LastSwiftMigration = 0940; TestTargetID = 607FACCF1AFB9204008FA782; }; @@ -474,6 +476,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = X4EYDGL7NV; INFOPLIST_FILE = SwiftLuhn/Info.plist; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; @@ -488,6 +491,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = X4EYDGL7NV; INFOPLIST_FILE = SwiftLuhn/Info.plist; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; @@ -500,6 +504,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = AA640ED277322E98AADE4DB9 /* Pods-SwiftLuhn_Tests.debug.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = X4EYDGL7NV; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -516,6 +521,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 8AD47538614B334D166DC901 /* Pods-SwiftLuhn_Tests.release.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = X4EYDGL7NV; INFOPLIST_FILE = Tests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/README.md b/README.md index 84e0764..b1c193f 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,8 @@ To run the unit test suite, please open the example project and hit CMD + U. ## Author Max Kramer, max@maxkramer.co, [@maxkramer](http://twitter.com/maxkramer) - +Elo, Hipercard and Aura by, [@bocato] +Elo update by, André Ferreira, [@andre991](https://github.com/andre991) ## License SwiftLuhn is available under the MIT license. See the LICENSE file for more info. diff --git a/SwiftLuhn.podspec b/SwiftLuhn.podspec index 343bae1..6e03960 100644 --- a/SwiftLuhn.podspec +++ b/SwiftLuhn.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SwiftLuhn' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'SwiftLuhn is a port of the Luhn algorithm, used for validating debit/credit card details.' s.description = <<-DESC This is a port of the Luhn Algorithm, generally used for validating debit/credit card details, to Swift. diff --git a/SwiftLuhn/Classes/SwiftLuhn.swift b/SwiftLuhn/Classes/SwiftLuhn.swift index c9298d4..8d52290 100644 --- a/SwiftLuhn/Classes/SwiftLuhn.swift +++ b/SwiftLuhn/Classes/SwiftLuhn.swift @@ -52,7 +52,7 @@ open class SwiftLuhn { case .elo: return "^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|50(9[0-9][0-9][0-9])|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|05([7-9])|06([0-9])|07([0-9])|08([0-9])|4([0-3][0-9]|8[5-9]|9[0-9])|5([0-9][0-9]|3[0-8])|9([0-6][0-9]|7[0-8])|7([0-2][0-9])|541|700|720|727|901)|65165([2-9])|6516([6-7][0-9])|65500([0-9])|6550([0-5][0-9])|655021|65505([6-7])|6516([8-9][0-9])|65170([0-4]))" case .hiperCard: - return "^(((637095)|(637612)|(637599)|(637609)|(637568))\d{0,10})$" + return "^(38|60)[0-9]{11,17}$" case .aura: return "^50[0-9]{14,17}$" } @@ -81,7 +81,7 @@ open class SwiftLuhn { case .elo: return "^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|50(9[0-9][0-9][0-9])|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|05([7-9])|06([0-9])|07([0-9])|08([0-9])|4([0-3][0-9]|8[5-9]|9[0-9])|5([0-9][0-9]|3[0-8])|9([0-6][0-9]|7[0-8])|7([0-2][0-9])|541|700|720|727|901)|65165([2-9])|6516([6-7][0-9])|65500([0-9])|6550([0-5][0-9])|655021|65505([6-7])|6516([8-9][0-9])|65170([0-4]))" case .hiperCard: - return "^(((637095)|(637612)|(637599)|(637609)|(637568))\d{0,10})$" + return "^(38|60)[0-9]{11,17}$" case .aura: return "^50[0-9]{14,17}$" } From 5bf56b5608df24f27c49916272a2c69ee078d992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:10:48 -0200 Subject: [PATCH 4/9] Removedoras Development Team --- Example/SwiftLuhn.xcodeproj/project.pbxproj | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Example/SwiftLuhn.xcodeproj/project.pbxproj b/Example/SwiftLuhn.xcodeproj/project.pbxproj index 6f41f54..6d8c3d3 100644 --- a/Example/SwiftLuhn.xcodeproj/project.pbxproj +++ b/Example/SwiftLuhn.xcodeproj/project.pbxproj @@ -218,12 +218,10 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - DevelopmentTeam = X4EYDGL7NV; LastSwiftMigration = 0940; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - DevelopmentTeam = X4EYDGL7NV; LastSwiftMigration = 0940; TestTargetID = 607FACCF1AFB9204008FA782; }; @@ -476,7 +474,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = X4EYDGL7NV; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = SwiftLuhn/Info.plist; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; @@ -491,7 +489,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = X4EYDGL7NV; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = SwiftLuhn/Info.plist; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; @@ -504,7 +502,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = AA640ED277322E98AADE4DB9 /* Pods-SwiftLuhn_Tests.debug.xcconfig */; buildSettings = { - DEVELOPMENT_TEAM = X4EYDGL7NV; + DEVELOPMENT_TEAM = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -521,7 +519,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 8AD47538614B334D166DC901 /* Pods-SwiftLuhn_Tests.release.xcconfig */; buildSettings = { - DEVELOPMENT_TEAM = X4EYDGL7NV; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Tests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; From 11504384b04a269e2e224c350a7b8e234809736a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:12:40 -0200 Subject: [PATCH 5/9] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b1c193f..b441c92 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,11 @@ To run the unit test suite, please open the example project and hit CMD + U. ## Author Max Kramer, max@maxkramer.co, [@maxkramer](http://twitter.com/maxkramer) + Elo, Hipercard and Aura by, [@bocato] + Elo update by, André Ferreira, [@andre991](https://github.com/andre991) + ## License SwiftLuhn is available under the MIT license. See the LICENSE file for more info. From 9f372fadae8c156fa438353fa72e780e32ed7d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:24:50 -0200 Subject: [PATCH 6/9] Added Tests. --- Example/Tests/CardTypeTest.swift | 5 ++++- README.md | 2 +- SwiftLuhn/Classes/SwiftLuhn.swift | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Example/Tests/CardTypeTest.swift b/Example/Tests/CardTypeTest.swift index c501d2d..49a7dc1 100644 --- a/Example/Tests/CardTypeTest.swift +++ b/Example/Tests/CardTypeTest.swift @@ -20,7 +20,10 @@ class CardTypeTest: XCTestCase { SwiftLuhn.CardType.jcb: "JCB", SwiftLuhn.CardType.maestro: "Maestro", SwiftLuhn.CardType.rupay: "Rupay", - SwiftLuhn.CardType.mir: "Mir" + SwiftLuhn.CardType.mir: "Mir", + SwiftLuhn.CardType.elo: "Elo", + SwiftLuhn.CardType.hipercard: "Hipercard", + SwiftLuhn.CardType.aura: "Aura" ] mapping.forEach { key, value in diff --git a/README.md b/README.md index b441c92..923cccf 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ You can also get the type of the card being used which will be one of: |Diner's Club| |JCB| |Elo| -|HiperCard| +|Hipercard| |Aura| ```swift diff --git a/SwiftLuhn/Classes/SwiftLuhn.swift b/SwiftLuhn/Classes/SwiftLuhn.swift index 8d52290..ce7b273 100644 --- a/SwiftLuhn/Classes/SwiftLuhn.swift +++ b/SwiftLuhn/Classes/SwiftLuhn.swift @@ -20,7 +20,7 @@ open class SwiftLuhn { case rupay case mir case elo - case hiperCard + case hipercard case aura } @@ -51,7 +51,7 @@ open class SwiftLuhn { return "^220[0-9]{13}$" case .elo: return "^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|50(9[0-9][0-9][0-9])|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|05([7-9])|06([0-9])|07([0-9])|08([0-9])|4([0-3][0-9]|8[5-9]|9[0-9])|5([0-9][0-9]|3[0-8])|9([0-6][0-9]|7[0-8])|7([0-2][0-9])|541|700|720|727|901)|65165([2-9])|6516([6-7][0-9])|65500([0-9])|6550([0-5][0-9])|655021|65505([6-7])|6516([8-9][0-9])|65170([0-4]))" - case .hiperCard: + case .hipercard: return "^(38|60)[0-9]{11,17}$" case .aura: return "^50[0-9]{14,17}$" @@ -80,7 +80,7 @@ open class SwiftLuhn { return "^220[0-9]+$" case .elo: return "^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|50(9[0-9][0-9][0-9])|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|05([7-9])|06([0-9])|07([0-9])|08([0-9])|4([0-3][0-9]|8[5-9]|9[0-9])|5([0-9][0-9]|3[0-8])|9([0-6][0-9]|7[0-8])|7([0-2][0-9])|541|700|720|727|901)|65165([2-9])|6516([6-7][0-9])|65500([0-9])|6550([0-5][0-9])|655021|65505([6-7])|6516([8-9][0-9])|65170([0-4]))" - case .hiperCard: + case .hipercard: return "^(38|60)[0-9]{11,17}$" case .aura: return "^50[0-9]{14,17}$" @@ -174,8 +174,8 @@ public extension SwiftLuhn.CardType { return "Mir" case .elo: return "Elo" - case .hiperCard: - return "HiperCard" + case .hipercard: + return "Hipercard" case .aura: return "Aura" } From e1fc44117bb9b007745198ae7c5626b67e06e8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:27:17 -0200 Subject: [PATCH 7/9] Converted to Swift 4.2 --- Example/Pods/Pods.xcodeproj/project.pbxproj | 9 +++++++-- Example/SwiftLuhn.xcodeproj/project.pbxproj | 12 ++++++------ Example/SwiftLuhn/AppDelegate.swift | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index d2d09af..55585fb 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -321,6 +321,11 @@ attributes = { LastSwiftUpdateCheck = 0930; LastUpgradeCheck = 0940; + TargetAttributes = { + FD216F00596C45B2B49C1B59E717145C = { + LastSwiftMigration = 1010; + }; + }; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; @@ -670,7 +675,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -703,7 +708,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/Example/SwiftLuhn.xcodeproj/project.pbxproj b/Example/SwiftLuhn.xcodeproj/project.pbxproj index 6d8c3d3..9199d5e 100644 --- a/Example/SwiftLuhn.xcodeproj/project.pbxproj +++ b/Example/SwiftLuhn.xcodeproj/project.pbxproj @@ -218,11 +218,11 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0940; + LastSwiftMigration = 1010; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0940; + LastSwiftMigration = 1010; TestTargetID = 607FACCF1AFB9204008FA782; }; }; @@ -479,7 +479,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -494,7 +494,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -510,7 +510,7 @@ INFOPLIST_FILE = Tests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftLuhn_Example.app/SwiftLuhn_Example"; }; name = Debug; @@ -523,7 +523,7 @@ INFOPLIST_FILE = Tests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftLuhn_Example.app/SwiftLuhn_Example"; }; name = Release; diff --git a/Example/SwiftLuhn/AppDelegate.swift b/Example/SwiftLuhn/AppDelegate.swift index 7033eb7..79bf376 100644 --- a/Example/SwiftLuhn/AppDelegate.swift +++ b/Example/SwiftLuhn/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } From a74f645f4d388fd8833a015fc1d8bb5e6c7b9635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:49:10 -0200 Subject: [PATCH 8/9] Added public function --- SwiftLuhn/Classes/SwiftLuhn.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SwiftLuhn/Classes/SwiftLuhn.swift b/SwiftLuhn/Classes/SwiftLuhn.swift index ce7b273..0335d49 100644 --- a/SwiftLuhn/Classes/SwiftLuhn.swift +++ b/SwiftLuhn/Classes/SwiftLuhn.swift @@ -87,7 +87,7 @@ open class SwiftLuhn { } } - class func performLuhnAlgorithm(with cardNumber: String) throws { + public class func performLuhnAlgorithm(with cardNumber: String) throws { let formattedCardNumber = cardNumber.formattedCardNumber() @@ -128,7 +128,7 @@ open class SwiftLuhn { } } - class func cardType(for cardNumber: String, suggest: Bool = false) throws -> CardType { + public class func cardType(for cardNumber: String, suggest: Bool = false) throws -> CardType { var foundCardType: CardType? for i in CardType.amex.rawValue...CardType.jcb.rawValue { From e489f1ad315a1bdc90ffaa72a7438ec7341cc0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Santana=20Ferreira?= Date: Tue, 8 Jan 2019 16:59:02 -0200 Subject: [PATCH 9/9] Update found card type --- SwiftLuhn/Classes/SwiftLuhn.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftLuhn/Classes/SwiftLuhn.swift b/SwiftLuhn/Classes/SwiftLuhn.swift index 0335d49..89dee3d 100644 --- a/SwiftLuhn/Classes/SwiftLuhn.swift +++ b/SwiftLuhn/Classes/SwiftLuhn.swift @@ -131,7 +131,7 @@ open class SwiftLuhn { public class func cardType(for cardNumber: String, suggest: Bool = false) throws -> CardType { var foundCardType: CardType? - for i in CardType.amex.rawValue...CardType.jcb.rawValue { + for i in CardType.amex.rawValue...CardType.aura.rawValue { let cardType = CardType(rawValue: i)! let regex = suggest ? suggestionRegularExpression(for: cardType) : regularExpression(for: cardType)