mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 07:23:12 -04:00
Allow full stops in SMS senders
We have a team who want their (short) web address as the text message sender. This commit updates the validation of text message senders to allow `.` as a valid character, which is currently blocking them from doing this. We can be fairly confident this works because: - the team are sending large volumes of messages already with their existing provider - we’ve tested it with all combinations of - both our text message providers - an Android phone and n iPhone
This commit is contained in:
@@ -35,7 +35,7 @@ from app.main.validators import (
|
|||||||
ValidGovEmail,
|
ValidGovEmail,
|
||||||
NoCommasInPlaceHolders,
|
NoCommasInPlaceHolders,
|
||||||
OnlyGSMCharacters,
|
OnlyGSMCharacters,
|
||||||
LettersAndNumbersOnly,
|
LettersNumbersAndFullStopsOnly,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -560,7 +560,7 @@ class ServiceSmsSenderForm(StripWhitespaceForm):
|
|||||||
validators=[
|
validators=[
|
||||||
DataRequired(message="Can’t be empty"),
|
DataRequired(message="Can’t be empty"),
|
||||||
Length(max=11, message="Enter 11 characters or fewer"),
|
Length(max=11, message="Enter 11 characters or fewer"),
|
||||||
LettersAndNumbersOnly(),
|
LettersNumbersAndFullStopsOnly(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
is_default = BooleanField("Make this text message sender the default")
|
is_default = BooleanField("Make this text message sender the default")
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ class OnlyGSMCharacters:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class LettersAndNumbersOnly:
|
class LettersNumbersAndFullStopsOnly:
|
||||||
|
|
||||||
regex = re.compile(r'^[a-zA-Z0-9\s]+$')
|
regex = re.compile(r'^[a-zA-Z0-9\s\.]+$')
|
||||||
|
|
||||||
def __init__(self, message='Use letters and numbers only'):
|
def __init__(self, message='Use letters and numbers only'):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|||||||
@@ -814,7 +814,7 @@ def test_incorrect_letter_contact_block_input(
|
|||||||
('', 'Can’t be empty'),
|
('', 'Can’t be empty'),
|
||||||
('abcdefghijkhgkg', 'Enter 11 characters or fewer'),
|
('abcdefghijkhgkg', 'Enter 11 characters or fewer'),
|
||||||
(' ¯\_(ツ)_/¯ ', 'Use letters and numbers only'),
|
(' ¯\_(ツ)_/¯ ', 'Use letters and numbers only'),
|
||||||
('blood.co.uk', 'Use letters and numbers only'),
|
('blood.co.uk', None),
|
||||||
])
|
])
|
||||||
def test_incorrect_sms_sender_input(
|
def test_incorrect_sms_sender_input(
|
||||||
sms_sender_input,
|
sms_sender_input,
|
||||||
|
|||||||
Reference in New Issue
Block a user