-
Notifications
You must be signed in to change notification settings - Fork 110
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
inconsistent normalization #93
Comments
ad 2. |
Regarding nr 3: it indeed is to 'know' we have a country code. There are some edge cases for which it isn't clear if the first digits is a country-code or just the plain number. |
Improvement regarding 2 welcome :) |
I'll have to think about it. I wrote the code but then I realized it might be problematic if phone number does have a country code but is not being recognized as correct. It's ok if we assume Phony is infallible and undefined behaviour for incorrect phone numbers is fine but it might be better to just leave the responsibility in the hands of users (in that situation we need to add The code below. It breaks two tests. |
Thx. I like to leave it in the hands of the user indeed :) |
@joost Just got bit by Show we default add_plus to false so it's 100% compatible with Phony? Otherwise, we should at least document it in the README |
Sample uses of normalization functions:
There are a few problems:
String#phony_normalized
's behaviour is not consistent withPhonyRails.normalize_number
add_plus
doesn't verify whether the number includes a country codeadd_plus
defaults to true whilePhony#split
andPhony#format
don't work with plusesad 1.
Should be easily fixed by passing all options to
PhonyRails.normalize_number
instead of justcountry_code
ad 2.
PhonyRails
should check whether phone number isPhony.plausible?
before appending+
ad 3.
What's the rationale behind
add_plus
defaulting totrue
? Is it to make clear the numbers are international? While it makes perfect sense, I believe it should default tofalse
for the sake of compatibility with Phony. It should at least be well documented on the front page.Let me know whether you agree with my comments and I can submit pull requests for all three points.
The text was updated successfully, but these errors were encountered: