Skip to content

Commit e246b76

Browse files
committed
fix: enhance phone number validation to check for unsupported country codes
1 parent 63f6d2a commit e246b76

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

notifications_utils/recipients.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,14 @@ def validate_phone_number(number, column=None, international=False):
505505
if len(number) < 8:
506506
raise InvalidPhoneError("Not enough digits")
507507

508-
if get_international_prefix(number) is None:
508+
prefix = get_international_prefix(number)
509+
if prefix is None:
509510
raise InvalidPhoneError("Not a valid country prefix")
510511

512+
# if the prefix is not in our billing rates, then we don't send to it, so we should error here
513+
if INTERNATIONAL_BILLING_RATES.get(prefix) is None:
514+
raise InvalidPhoneError("Country code {} is not supported".format(prefix))
515+
511516
return number
512517

513518

0 commit comments

Comments
 (0)