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

US Number is not getting recognized #129

Open
vishalsanghai opened this issue Oct 22, 2024 · 3 comments
Open

US Number is not getting recognized #129

vishalsanghai opened this issue Oct 22, 2024 · 3 comments

Comments

@vishalsanghai
Copy link

vishalsanghai commented Oct 22, 2024


	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

@jiyamathias
Copy link

jiyamathias commented Nov 20, 2024

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

@twocs
Copy link

twocs commented Feb 2, 2025

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

@jiyamathias
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants