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

Phony 2.1 incompatibility related to country codes/numbers #48

Closed
pjg opened this issue Feb 18, 2014 · 0 comments · Fixed by #49
Closed

Phony 2.1 incompatibility related to country codes/numbers #48

pjg opened this issue Feb 18, 2014 · 0 comments · Fixed by #49

Comments

@pjg
Copy link
Contributor

pjg commented Feb 18, 2014

In phony_validator, in the common case, a country code is passed to the Phony.plausible? method:

@record.errors.add(attribute, error_message) if not Phony.plausible?(value, cc: country_code_or_country_number)

While Phony expects cc to be specifically a country number, otherwise the phone number will not be plausible.

Phony.plausible?('+1 555 1234 123', cc: 'US')
=> false

Phony.plausible?('+1 555 1234 123', cc: '1')
=> true

The solution is to do the ISO3166::Country::Data conversion from country code to country number.

I'll try to create a PR for that this week.

pjg added a commit to pjg/phony_rails that referenced this issue Feb 23, 2014
In `PhonyPlausibleValidator`.

You cannot pass country code (like 'NL') to `Phony.plausible?` as it
allows only country numbers (like '31'):

    Phony.plausible?('+1 555 1234 123', cc: 'US')
    => false

    Phony.plausible?('+1 555 1234 123', cc: '1')
    => true

Also make a strong distinction between country codes and country numbers
and don't use one when you mean the other.

Fixes joost#48.
@joost joost closed this as completed in #49 Feb 24, 2014
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

Successfully merging a pull request may close this issue.

1 participant