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

Using a number different from the country #97

Closed
phillipp opened this issue Jun 17, 2015 · 3 comments
Closed

Using a number different from the country #97

phillipp opened this issue Jun 17, 2015 · 3 comments

Comments

@phillipp
Copy link
Contributor

Hi,
thanks for this great gem! I'm not sure if this is is a phony or phony_rails issue:

I have a validation in the model that goes like this:

phony_normalize :phone
  validates :phone, phony_plausible: true, presence: true

This works fine when the user wants to add a number that has the same country code/prefix than the country_code from the address. If the user types a number from another country, prefixed by + so that it's clear that there already is a country code the country prefix from the record's country code is added.

Is that a bug or a feature? In this case I want that the user can specify a number from another country, but the number is prefixed by default with the country prefix from the record's country_code. Is that possible? I saw that there is an undocumented ignore_record_country_code option but that seems to ignore the country code at all.

@joost
Copy link
Owner

joost commented Jun 18, 2015

Lets ask @cinconnu .. creator of the validation stuff.

@ddidier
Copy link

ddidier commented Jun 18, 2015

I don't remember well since it has been quite some time... but I think you actually can tell that's a bug, or at least the feature was overlooked :)
I don't have any time to fix this but I took a look at the code and the + sign should be taken into account in the validate_each method of PhonyPlausibleValidator. There should be 2 cases, validate without the country code if the + sign is present at the start of the number, use the current code otherwise.

@phillipp
Copy link
Contributor Author

So I assume a pull request is welcome?

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