Skip to content

Commit

Permalink
Make provisions for edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
elviva-mgp committed Jul 19, 2024
1 parent 47927fb commit 17e862d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Examples/MangopayDemo/MangopayDemo/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string></string>
<string>DDA9.1</string>
</array>
</dict>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public class MGPPaymentForm: UIView, FormValidatable {

private func formatExpiryDate(_ text: String) -> String {
var cleanedText = text.replacingOccurrences(of: "/", with: "")

if cleanedText.isEmpty {
return ""
}
Expand All @@ -321,7 +321,16 @@ public class MGPPaymentForm: UIView, FormValidatable {
cleanedText = "0" + cleanedText
}
}


if cleanedText.count == 2 {
let firstDigit = cleanedText.first
let secondDigit = cleanedText[cleanedText.index(cleanedText.startIndex, offsetBy: 1)]

if let digit = secondDigit.wholeNumberValue, digit > 2 && digit < 10 && firstDigit?.wholeNumberValue == 1 {
cleanedText.replaceSubrange(cleanedText.startIndex...cleanedText.startIndex, with: "0\(cleanedText.first!)")
}
}

if cleanedText.count > 2 {
let index = cleanedText.index(cleanedText.startIndex, offsetBy: 2)
cleanedText.insert("/", at: index)
Expand Down

0 comments on commit 17e862d

Please sign in to comment.