From f79c2e86a9f97737abe1325b76c610c87b7c0d0c Mon Sep 17 00:00:00 2001 From: Bobby Date: Thu, 6 Oct 2022 18:35:43 -0400 Subject: Fixed validation for special phone numbers --- src/edify/library/phone.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/edify/library/phone.py b/src/edify/library/phone.py index 90ab535..362fa97 100644 --- a/src/edify/library/phone.py +++ b/src/edify/library/phone.py @@ -1,6 +1,7 @@ import re pattern = "^\\+?\\d{1,4}?[-.\\s]?\\(?\\d{1,3}?\\)?[-.\\s]?\\d{1,4}[-.\\s]?\\d{1,4}[-.\\s]?\\d{1,9}$" +special_pattern = r"^\d{2,4}" def phone_number(phone: str) -> bool: @@ -12,7 +13,7 @@ def phone_number(phone: str) -> bool: bool: True if the string is a valid phone number, False otherwise. """ - if re.match(pattern, phone): + if re.match(pattern, phone) or re.match(special_pattern, phone): return True else: return False -- cgit v1.2.3