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

Improving formatting for possible (but not valid) numbers? #284

Closed
alexeyr-ci opened this issue Jun 29, 2023 · 2 comments
Closed

Improving formatting for possible (but not valid) numbers? #284

alexeyr-ci opened this issue Jun 29, 2023 · 2 comments

Comments

@alexeyr-ci
Copy link
Contributor

alexeyr-ci commented Jun 29, 2023

E.g. +15555555555 is possible but not valid. So I get

[1] pry(main)> phone = Phonelib.parse("+15555555555")
...
[2] pry(main)> phone.international
"+15555555555"                    
[3] pry(main)> phone.national
"5555555555" 

Still it's clear it should be formatted as (555) 555-55-55 nationally, and +1 555-555-55-55 internationally, and indeed if I do Phonelib.add_additional_regex :us, Phonelib::Core::MOBILE, '555\d{7}', Phonelib knows how to format it.

Indeed, https://libphonenumber.appspot.com/phonenumberparser?number=%2B15555555555 gives

Original format	+1 555-555-5555
National format	(555) 555-5555
International format	invalid

but from its code I think invalid is due to an explicit check and "Original format" is the international format in this case.

Is it possible to change the formatting methods to work in this way or at least to add an option?

daddyz added a commit that referenced this issue Sep 26, 2023
@daddyz
Copy link
Owner

daddyz commented Sep 26, 2023

@alexeyr-ci changed behaviour in v0.8.4 to provide formatted result when number is possible instead of valid

@daddyz daddyz closed this as completed Sep 26, 2023
@tilo
Copy link

tilo commented Feb 14, 2024

@daddyz a version change from 0.8.3 to 0.9.0 might have been better here, well actually from 0.9.x to 0.10.0 because of the other breaking change earlier
#297 (comment)

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