Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Example/Tests/CardTypeTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ 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.unionpay: "Unionpay"
]

mapping.forEach { key, value in
Expand Down
9 changes: 9 additions & 0 deletions SwiftLuhn/Classes/SwiftLuhn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ open class SwiftLuhn {
case maestro
case rupay
case mir
case unionpay
}

public enum CardError: Error {
Expand Down Expand Up @@ -46,6 +47,8 @@ open class SwiftLuhn {
return "^6[0-9]{15}$"
case .mir:
return "^220[0-9]{13}$"
case .unionpay:
return "^62[0-9]{14}$"
}
}

Expand All @@ -69,6 +72,8 @@ open class SwiftLuhn {
return "^6[0-9]+$"
case .mir:
return "^220[0-9]+$"
case .unionpay:
return "^62[0-9]+$"
}
}

Expand Down Expand Up @@ -157,6 +162,8 @@ public extension SwiftLuhn.CardType {
return "Rupay"
case .mir:
return "Mir"
case .unionpay:
return "Unionpay"
}
}

Expand All @@ -180,6 +187,8 @@ public extension SwiftLuhn.CardType {
self.init(rawValue: 7)
case "mir":
self.init(rawValue: 8)
case "unionpay":
self.init(rawValue: 9)
default:
return nil
}
Expand Down