mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
Validate International phone numbers
- uses new utils methods to validate phone numbers - defaults to International=True on validation. This ensures the validator works on all numbers - Then check if the user can send this message to the number internationally if needed.
This commit is contained in:
+2
-2
@@ -324,13 +324,13 @@ class SmsNotificationSchema(NotificationSchema):
|
||||
@validates('to')
|
||||
def validate_to(self, value):
|
||||
try:
|
||||
validate_phone_number(value)
|
||||
validate_phone_number(value, international=True)
|
||||
except InvalidPhoneError as error:
|
||||
raise ValidationError('Invalid phone number: {}'.format(error))
|
||||
|
||||
@post_load
|
||||
def format_phone_number(self, item):
|
||||
item['to'] = validate_and_format_phone_number(item['to'])
|
||||
item['to'] = validate_and_format_phone_number(item['to'], international=True)
|
||||
return item
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user