Skip to content

US Number is not getting recognized #129

Description

@vishalsanghai

	phoneNumber := "+15551234567"
	num, err := libphonenumber.Parse(phoneNumber, "")
	if err != nil {
		fmt.Printf("Error parsing phone number: %v\n", err)
		return
	}
	if libphonenumber.IsValidNumber(num) {
		fmt.Println("The phone number is valid.")
	} else {
		fmt.Println("The phone number is not valid.")
	}

Why is this valid US number being marked as not valid?
However another US number works fine : +14155552671

Activity

  1. jiyamathias commented on Nov 20, 2024

    @jiyamathias

    Hello @vishalsanghai,
    I am having a similar issue with the recent set of Nigerian number that starts with 091 meanwhile other numbers that starts with 090, 081 and so on works just fine. I would try and address the issue.
    Do have a wonderful day

  2. twocs commented on Feb 2, 2025

    @twocs

    The simple answer is that there is no area code 555 in the US. Therefore, +15551234567 is not a valid number.

    This is not anything unique to this library. You will also see the same behaviour in google/libphonenumber so it would be a bug if ttacon/libphonenumber recognised a 555 number.

    I found an online phone number parser and confirmed that is expected behaviour.

    555 Not real area code - https://libphonenumber.appspot.com/phonenumberparser?number=%2B15551234567
    415 San Francisco, CA - https://libphonenumber.appspot.com/phonenumberparser?number=%2B14155552671

  3. jiyamathias commented on Feb 2, 2025

    @jiyamathias

    This library github.com/ttacon/libphonenumber is not up to date with github.com/google/libphonenumber. To handle phone number validation on your platforms, I will suggest you use this library instead github.com/nyaruka/phonenumbers. It is a fork of github.com/ttacon/libphonenumber, and it is updated with this library github.com/google/libphonenumber. That was, you would have no issue with validating recent sets of numbers (at least in my case, I can sign up using my phone number now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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