Skip to content

Commit

Permalink
Refactor VonageDriver to use phonenumbers library for phone number va…
Browse files Browse the repository at this point in the history
…lidation
  • Loading branch information
josephmancuso committed Oct 23, 2024
1 parent 3998f7a commit 48e739c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/masonite/notification/drivers/vonage/VonageDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def _handle_errors(self, response):
)

def is_valid_phone_number(self, phone_number):
# Add your phone number validation logic here
# For example, check if it is a 10-digit number
return phone_number.isdigit() and len(phone_number) == 10
import phonenumbers
try:
parsed_number = phonenumbers.parse(phone_number, None)
return phonenumbers.is_valid_number(parsed_number)
except phonenumbers.NumberParseException:
return False

0 comments on commit 48e739c

Please sign in to comment.