-
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
Validation fails if record country code does not match code in phone number #55
Comments
Couldn't you use something like a |
I don't think that would get the job done in this case. Even if the phone number's country code doesn't match the country stored on the record, we still want to run it through the validator and set error messages for obviously bad numbers. We're not looking to not validate in certain cases. We just don't want to require that the country code on the phone matches the country stored on the record. |
How can you validate a number if you don't have a |
The country code is supplied in the number, but that number doesn't match the country stored on the record. When Here are some examples (number redacted for obvious reasons):
And here's the equivalent of what's getting called in the validator:
I'm looking to make supplying the country code via the |
I guess the validator could use some options like: Pull request welcome :) |
Do you see those as booleans? Like, they could be set to false and that would skip supplying them to |
This is an interesting problem. I would suggest something a little bit more global, i.e. a setting called |
Use case: Suppose you moved to Thailand but still have a Japanese phone number (not contrived-- seeing this in production).
Heart of the issue: The validator has this line
@record.errors.add(attribute, error_message) if not Phony.plausible?(value, cc: country_number)
. That call tocountry_number
will first look to see if a country code was supplied in the options. Then it will check to see if the record has a country code. If it doesn't have that, then it checks to see if the record has a country, which it then uses to look up a country code.So, passing in nil as the country_number option won't work, because the validator will fallback to looking things up on the record.
So, I realize I could rename columns on my models, but for obvious reasons I'd rather avoid that.
2 questions:
Thanks!
The text was updated successfully, but these errors were encountered: