Validate phone numbers
In addition to parsing the number, we can also validate it with the phonenumbers library. issue6567 review42411002
This commit is contained in:
1 parent
943ff95c89
commit
aeeef86012
1 file changed
+3
-1
@@ -259,8 +259,10 @@ class ContactMechanism(sequence_ordered(), ModelSQL, ModelView):
|
||||
if not phonenumbers or self.type not in _PHONE_TYPES:
|
||||
return
|
||||
try:
|
||||
phonenumbers.parse(self.value)
|
||||
phonenumber = phonenumbers.parse(self.value)
|
||||
except NumberParseException:
|
||||
phonenumber = None
|
||||
if not (phonenumber and phonenumbers.is_valid_number(phonenumber)):
|
||||
self.raise_user_error(
|
||||
'invalid_phonenumber', {
|
||||
'phone': self.value,
|
||||
|
||||
Reference in new issue
Block a user