aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-10-06 18:41:17 -0400
committerGitHub <[email protected]>2022-10-06 18:41:17 -0400
commit3dfdd675e661f32f7373a521ad66ab56f637e0c4 (patch)
tree8fb6c3d2ff69564fe25cc4c1dce219dbcfa8b28d /src
parent155f2499d15bab010e79b24f96d77758a87b7bbc (diff)
parentf79c2e86a9f97737abe1325b76c610c87b7c0d0c (diff)
downloadedify-3dfdd675e661f32f7373a521ad66ab56f637e0c4.tar.xz
edify-3dfdd675e661f32f7373a521ad66ab56f637e0c4.zip
Fixed validation for special phone numbers (#19)
Fixes #16
Diffstat (limited to 'src')
-rw-r--r--src/edify/library/phone.py3
1 files changed, 2 insertions, 1 deletions
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