Use phonenumbers package to validate live settings twilio number instead of regex to support EU number
This commit is contained in:
parent
3db4038a4f
commit
edac2e334f
1 changed files with 3 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import json
|
|||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import phonenumbers
|
||||
from django.apps import apps
|
||||
from python_http_client import UnauthorizedError
|
||||
from sendgrid import SendGridAPIClient
|
||||
|
|
@ -125,7 +126,8 @@ class LiveSettingValidator:
|
|||
|
||||
@staticmethod
|
||||
def _is_phone_number_valid(phone_number):
|
||||
return re.match(r"^\+\d{11}$", phone_number)
|
||||
ph_num = phonenumbers.parse(phone_number)
|
||||
return phonenumbers.is_valid_number(ph_num)
|
||||
|
||||
@staticmethod
|
||||
def _prettify_twilio_error(exc):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue