Rational
Since the addition of phone numbers validation the phone number requires the international prefix in order to be validated. It is quite common for the users to omit the international prefix when using their own local format.
Currently this causes an astonish behavior as they get an error about an invalid from number which is right for them (using their region format)
Proposal
Add a configuration value on the party configuration which will be only visible when the phonenumbers library is installed in order to specify the region to be used on validation.
If this configuration is set it will be used as region when parsing the number. Note that the region is ignored when using an international prefix:
>>> from phonenumbers import parse
>>> parse('666666666', 'ES')
PhoneNumber(country_code=34, national_number=666666666, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None)
>>> parse('+33666666666', 'ES')
PhoneNumber(country_code=33, national_number=666666666, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None)
>>> parse('0033666666666', 'ES')
PhoneNumber(country_code=33, national_number=666666666, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None)
>>> parse('033666666666', 'ES')
PhoneNumber(country_code=34, national_number=33666666666, extension=None, italian_leading_zero=True, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None)
>>> parse('0034666666666', 'ES')
PhoneNumber(country_code=34, national_number=666666666, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None)
A list of available regions can be obtained with:
phonenumbers.phonenumberutil.SUPPORTED_REGIONS
So I propose to add a selection field with only the available options so we prevent selecting wrong values