stefanfoulis / django-phonenumber-field

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

The phone number entered is not valid, #355

Closed Singh-Sg closed 2 years ago

Singh-Sg commented 4 years ago

model: phone_number_telenor = PhoneNumberField(blank=True, help_text='related person\'s phone number')

input_number I'm trying: 9337382971 (Myanmar)

Django1.11.28, django-phonenumber-field4.0.0

All other number working Could you please help me with this.

amateja commented 2 years ago

Hi @Singh-Sg,

Please note my code snippet:

>>> import phonenumbers
>>> 
>>> region = 'MM'
>>> numbers = (
...     '9337382971',  # your example
...     '+959337382971',  # your example international format
...     '+95673407225',  # Myanmar Ministry of Transport and Communications
... )
>>> for number_str in numbers:
...     number = phonenumbers.parse(number=number_str, region=region)
...     print(number_str, phonenumbers.is_valid_number(number))
... 
9337382971 False
+959337382971 False
+95673407225 True

This package is just a wrapper around python-phonenumbers with tones of goodies. When you have some issue with your phone number usually it means that python-phonenumbers is not able to parse it.

I couldn't also find your phone number pattern in official ITU-T numbering plans: https://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000920017PDFE.pdf https://www.itu.int/oth/T0202000092/en

amateja commented 2 years ago

Closing as there is no followup from the reporter and the issue was due to python-phonenumbers dependency.