-
Notifications
You must be signed in to change notification settings - Fork 23k
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
[FIX] phone_validation: Support french mobile numbers starting with 7 #165160
base: 15.0
Are you sure you want to change the base?
[FIX] phone_validation: Support french mobile numbers starting with 7 #165160
Conversation
ced1d72
to
b68e8ce
Compare
b68e8ce
to
937f7f9
Compare
Mobile numbers in France start with 06 or 07 (ref1, ref2) Currently used phonenumbers library (8.12.1) doesn't support numbers starting with 07, neither the (currently) newest version of the phonenumbers library (8.13.36) This commit modifies the new version of the phonenumbers metadata for French mobile numbers adding support for mobile numbers starting with 7. [Reproduce] - Install phone_validation,contacts - Set company country to France - Add contact with correct French NATIONAL number starting with 07 - BUG: +33 is not added in front of the number (ref.1) https://en.wikipedia.org/wiki/Telephone_numbers_in_France (ref.2) https://www.itu.int/oth/T020200004A/en opw-3860059
937f7f9
to
7452390
Compare
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.
If I compare the two regexes, I get this:
(old on left, new on right)
So 7 as beginning was already accepted but only if it was followed by a figure from 3 to 9. This corresponds (a little wider) to https://www.itu.int/oth/T020200004A/en that says numbers from 730 to 789 are used for mobile numbers.
With this change to the files we also accepts numbers beginning by 700 to 729 as mobile numbers. In the linked document, the only valid phone numbers in this range seems to be "7000" to "7004" but they are 13 digits instead of 9 and used for "Mobile numbers for machine to machine" not normal mobile numbers:
So as far as I can tell the change to the current version seems to not be useful since "07 01 43 78 61" doesn't seem to be a valid french number, but maybe I'm missing something.
If it was a real issue that needs to be solved, looks good to me with comment taken into account.
PHONE_METADATA_FR = PhoneMetadata(id='FR', country_code=33, international_prefix='00', | ||
general_desc=PhoneNumberDesc(national_number_pattern='[1-9]\\d{8}', possible_length=(9,)), | ||
fixed_line=PhoneNumberDesc(national_number_pattern='(?:26[013-9]|59[1-35-9])\\d{6}|(?:[13]\\d|2[0-57-9]|4[1-9]|5[0-8])\\d{7}', example_number='123456789', possible_length=(9,)), | ||
mobile=PhoneNumberDesc(national_number_pattern='(?:[67](?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)), |
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.
if the intent of the change of the original file:
- mobile=PhoneNumberDesc(national_number_pattern='(?:6(?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)),
+ mobile=PhoneNumberDesc(national_number_pattern='(?:[67](?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)),
is to add numbers beginning by 70 to 72, it would be cleaner to do it like this:
mobile=PhoneNumberDesc(national_number_pattern='(?:[67](?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)), | |
mobile=PhoneNumberDesc(national_number_pattern='(?:6(?:[0-24-8]\\d|3[0-8]|9[589])|7\\d{2})\\d{6}', example_number='612345678', possible_length=(9,)), |
thanks for having a look @nle-odoo I'm going to contact the person raising this issue, to get the actual problematic number, cause now I see that this seem like forcing an exception that shouldn't exist |
[FIX] phone_validation: Support french mobile numbers starting with 7
Mobile numbers in France start with 06 or 07 (ref1, ref2)
Currently used phonenumbers library (8.12.1) doesn't support numbers starting with 07,
neither the (currently) newest version of the phonenumbers library (8.13.36)
This commit modifies the new version of the phonenumbers metadata for French
mobile numbers adding support for mobile numbers starting with 7.
[Reproduce]
(ref.1)
https://en.wikipedia.org/wiki/Telephone_numbers_in_France
(ref.2)
https://www.itu.int/oth/T020200004A/en
opw-3860059