Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AUBecs minlen 4, maxlen 9 #4258

Merged
merged 1 commit into from
Nov 14, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### PaymentSheet
* [Fixed] Fixed an issue with the vertical list with 3 or more saved payment methods where tapping outside the screen sometimes drops changes that were made (e.g. removal or update of PMs).
* [Fixed] Fixed an issue where the dialog when removing a co-branded card may show the incorrect card brand.
* [Fixed] Fixed issue preventing users to enter in 4 digit account numbers for AU Becs.

## 24.0.0 2024-11-04
### PaymentSheet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,19 @@ import UIKit
String.Localized.incompleteAccountNumber)
let label = String.Localized.accountNumber
let disallowedCharacters: CharacterSet = .stp_invertedAsciiDigit
let numberOfDigitsRequired = 9
let minimumNumberOfDigits = 4
let maximumNumberofDigits = 9

func maxLength(for text: String) -> Int {
return numberOfDigitsRequired
return maximumNumberofDigits
}
let defaultValue: String?

public func validate(text: String, isOptional: Bool) -> TextFieldElement.ValidationState {
if text.isEmpty {
return isOptional ? .valid : .invalid(Error.empty)
}
return text.count == numberOfDigitsRequired ? .valid : .invalid(AUBECSAccountNumberConfiguration.incompleteError)
return text.count >= minimumNumberOfDigits && text.count <= maximumNumberofDigits ? .valid : .invalid(AUBECSAccountNumberConfiguration.incompleteError)
}

func keyboardProperties(for text: String) -> TextFieldElement.KeyboardProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class TextFieldElementAccountFactoryTest: XCTestCase {
func testAUBECSAccountNumberConfiguration_validAccountNumber() {
let bsb = TextFieldElement.Account.AUBECSAccountNumberConfiguration(defaultValue: nil)

bsb.test(text: "1234", isOptional: false, matches: .valid)
bsb.test(text: "12345", isOptional: false, matches: .valid)
bsb.test(text: "123456", isOptional: false, matches: .valid)
bsb.test(text: "1234567", isOptional: false, matches: .valid)
bsb.test(text: "12345678", isOptional: false, matches: .valid)
bsb.test(text: "000123456", isOptional: false, matches: .valid)
}

Expand All @@ -52,11 +57,6 @@ class TextFieldElementAccountFactoryTest: XCTestCase {
bsb.test(text: "0", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "00", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "000", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "0001", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "00012", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "000123", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "0001234", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
bsb.test(text: "00012345", isOptional: false, matches: .invalid(TextFieldElement.Account.AUBECSAccountNumberConfiguration.incompleteError))
}

}
Loading