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

Decide on whether Phony handles the + #436

Open
floere opened this issue Apr 22, 2019 · 2 comments
Open

Decide on whether Phony handles the + #436

floere opened this issue Apr 22, 2019 · 2 comments

Comments

@floere
Copy link
Owner

floere commented Apr 22, 2019

Should Phony also handle the + (country calling code indicator) when passed to e.g. split?

@capripot
Copy link

capripot commented Jun 11, 2023

I'd say yes! For instance, currently I use phony_normalize from phony-rails, which saves a number with a + in DB.

But then, when I try to format it in national format, if I leave the +, I get a Phony::FormattingError: Phony could not format the given number. Is it a phone number? error. So I need to remove the + before passing it to #format.

Could #format just handle the + for me?

@floere
Copy link
Owner Author

floere commented Jun 11, 2023

@capripot Thanks for your input, I appreciate it! 😊
I think the core issue here is that it makes little sense to also store a + in the database, if you only store full E164 conforming numbers (not sure I agree with phony-rails' decision here to leave the + in – but I am missing context, I assume). format is designed to work only on E164 numbers, ie. only the digits. Feel free to call normalize beforehand and call format on the result. Does that help?

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

2 participants