misc: reinforce french phonenumber validation (#73860)
gitea-wip/wcs/pipeline/pr-main This commit looks good Details
gitea/wcs/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Thomas NOËL 2023-01-26 09:39:37 +01:00
parent eb70e9eb43
commit f22e7b4ad7
2 changed files with 4 additions and 0 deletions

View File

@ -647,6 +647,7 @@ def test_validate_phone_fr():
'1234559',
'+32123456789',
'01+23+45+67+89',
'tel 0143350133',
]
assert all(validate_phone_fr(pn) for pn in valid)

View File

@ -835,6 +835,9 @@ def is_ascii_digit(string_value):
def validate_phone_fr(string_value):
if not re.match(r'^[0\+][\d\.\s]+$', string_value):
# leading zero or +, then digits, dots, or spaces
return False
french_country_codes = [33, 262, 508, 590, 594, 596]
pn = None
try: