stefanfoulis / django-phonenumber-field

A django model and form field for normalised phone numbers using python-phonenumbers
MIT License
1.48k stars 318 forks source link

Updated PhoneNumber.from_string() classmethod to not raise an exception if no region is specified #586

Closed Naggafin closed 8 months ago

Naggafin commented 9 months ago

A very simple fix. PhoneNumber.from_string() allows for one to not specify the region kwarg, but the way It was interfacing with python-phonenumbers would make doing so result in an exception being thrown 100% of the time. This seems like unintended behavior, given region is not a required argument (not to mention I had a specific use case for this), so I changed it to instruct python-phonenumbers to only attempt to validate the region if one was specified, but otherwise to ignore regional validation.