Skip to content

Partial Formatter with "US" default region breaks for phone numbers starting with "3" #714

Description

@katmarshgriffin

New Issue Checklist

Steps to reproduce

Using PartialFormatter, set the default region to US, and start entering a phone number beginning with "3"

Expected result

Formats to "3"

Actual result

Formats to "(3"

Environment

SPM

Notes

  • All other numbers appear to format correctly.
  • Numbers beginning with "3" also format correctly when the country code is provided before the "3".
  • Tested on the javascript version with the number "3362530000" and AsYouTypeFormatter Results are correct.
  • I updated the testUSTollFreeNumber() unit test to start with a "3" instead of an "8". This caused the test to fail, same reasoning as expected result and actual result note. Adding updated test below
        let partialFormatter = PartialFormatter(phoneNumberKit: phoneNumberKit, defaultRegion: "US")
        var testNumber = "3"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "3")
        testNumber = "33"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "33")
        testNumber = "336"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "336")
        testNumber = "3362"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "336-2")
        testNumber = "33625"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "336-25")
        testNumber = "336253"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "336-253")
        testNumber = "3362530"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "336-2530")
        testNumber = "33625300"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "(336) 253-00")
        testNumber = "336253000"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "(336) 253-000")
        testNumber = "3362530000"
        XCTAssertEqual(partialFormatter.formatPartial(testNumber), "(336) 253-0000")
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions