Skip to content

Commit

Permalink
Merge branch 'develop' into feature/enable-formitemtoggleview-externa…
Browse files Browse the repository at this point in the history
…l-testability
  • Loading branch information
goergisn authored Oct 28, 2024
2 parents 1c247d3 + 805bdb6 commit e566032
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AdyenCard/Form/FormCardNumberItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal final class FormCardNumberItem: FormTextItem, AdyenObserver {
let isAdding = formattedText.count > text.count

let oldNumberOfSpacesBeforeCursor = text.numberOfSpaces(beforeOffset: oldCursorOffset)

let projectedNewCursorOffset = oldCursorOffset + replacementLength + (isAdding ? 1 : 0)
let newNumberOfSpacesBeforeCursor = formattedText.numberOfSpaces(
beforeOffset: projectedNewCursorOffset
Expand Down
6 changes: 5 additions & 1 deletion AdyenCard/Formatters/CardExpiryDateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ import Foundation
/// The input is expected to be sanitized as "MMYY", which will result in "MM / YY".
public final class CardExpiryDateFormatter: NumericFormatter {

override public func sanitizedValue(for value: String) -> String {
super.sanitizedValue(for: value).adyen.truncate(to: maxLength)
}

override public func formattedValue(for value: String) -> String {
let separator = " / "

let sanitizedString = sanitizedValue(for: value).adyen.truncate(to: maxLength)
let sanitizedString = sanitizedValue(for: value)

var formattedDate = sanitizedString
var month = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class CardExpiryDateFormatterTests: XCTestCase {
XCTAssertEqual(sut.sanitizedValue(for: "09 / "), "09")
XCTAssertEqual(sut.sanitizedValue(for: "10 / 1"), "101")
XCTAssertEqual(sut.sanitizedValue(for: "09 / 21"), "0921")
XCTAssertEqual(sut.sanitizedValue(for: "09 / 213"), "0921")
}

func testNonDecimalDigitSanitizing() {
Expand Down

0 comments on commit e566032

Please sign in to comment.