-
Notifications
You must be signed in to change notification settings - Fork 315
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
Remove non-geo phone numbers from the SplitPhoneNumberWidget #614
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔will this cause problems for people who have built things around the old behaviour?
Finally came back to this PR.
They couldn’t. Using the field with a def test_nongeo(self):
class PhoneNumberForm(forms.Form):
number = SplitPhoneNumberField()
nongeo_country_code = list(phonenumbers.COUNTRY_CODES_FOR_NON_GEO_REGIONS)[0]
nongeo_region_code = phonenumbers.COUNTRY_CODE_TO_REGION_CODE[
nongeo_country_code
][0]
form = PhoneNumberForm(
{
"number_0": nongeo_region_code,
"number_1": "800-002-1244",
}
)
self.assertIs(form.is_valid(), False) Outputs:
Besides, according to the list of phone numbers country code on Wikipedia, the non-geo codes are:
These numbers are unlikely to legitimately appear in a standard app. |
The COUNTRY_CODE_TO_REGION_CODE dict contains values that are not specific to a region code: the COUNTRY_CODES_FOR_NON_GEO_REGIONS. These country codes are international, and are not a good fit for the SplitPhoneNumberWidget, which offers to select a region, then fill in the national number.
ac1be9d
to
57192ac
Compare
The
COUNTRY_CODE_TO_REGION_CODE
dict contains values that are not specific to a region code: theCOUNTRY_CODES_FOR_NON_GEO_REGIONS
. These country codes are international, and are not a good fit for theSplitPhoneNumberWidget
, which offers to select a region, then fill in the national number.Fixes #605