Decide on whether Phony handles the +
floere opened this issue · 2 comments
Should Phony also handle the + (country calling code indicator) when passed to e.g. split
?
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?
@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?