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

Add enforce_record_country option to phony_normalize method #98

Merged
merged 1 commit into from
Jun 19, 2015

Conversation

phillipp
Copy link
Contributor

I added an option for the behaviour I described in #97.

class Foobar < ActiveRecord::Base
  phony_normalize :phone_number, enforce_record_country: false
end

If you turn the option off the country_code of the record will be passed to the PhonyRails.normalize_number as the default_country_code instead of the country_code. In effect the country number won't be force added so the user can specify a number from a different country than the country_code indicates.

I had to add a new model for the specs because I didn't see a non-hackish way to change the existing model.

Maybe the option name could be better, but that can easily be changed.

The option defaults to true for conssistent behaviour.
If you turn it off and the records phone number is prefixed
by a plus sign the records country_code will not be added
as the country number.
joost pushed a commit that referenced this pull request Jun 19, 2015
Add enforce_record_country option to phony_normalize method
@joost joost merged commit c57fdf4 into joost:master Jun 19, 2015
@phillipp phillipp deleted the prefix-validation branch June 21, 2015 01:07
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 this pull request may close these issues.

2 participants