mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 12:19:47 -04:00
Update SMS sender validation to reject senders starting with 00
Having SMS senders that start with 00 can cause issues with Firetext due to Firetext's validation rules, so we shouldn't allow SMS senders to start with 00. Firetext treats a double 00 at the start of the senderID as an international prefix, so removes them. A sender of 00447876574016 would become 447876574016. Under Firetext's validation rules, an SMS sender of five 0s (00000) would become 4400. This is because the first 00 are removed (as the international prefix). The third 0 is seen as the start of a phone number, and becomes 44, leaving the final 00 = 4400.
This commit is contained in:
@@ -92,3 +92,13 @@ class LettersNumbersAndFullStopsOnly:
|
||||
def __call__(self, form, field):
|
||||
if field.data and not re.match(self.regex, field.data):
|
||||
raise ValidationError(self.message)
|
||||
|
||||
|
||||
class DoesNotStartWithDoubleZero:
|
||||
|
||||
def __init__(self, message="Can't start with 00"):
|
||||
self.message = message
|
||||
|
||||
def __call__(self, form, field):
|
||||
if field.data and field.data.startswith("00"):
|
||||
raise ValidationError(self.message)
|
||||
|
||||
Reference in New Issue
Block a user