diff --git a/app/main/forms.py b/app/main/forms.py index 90dd618be..b8af1c9dc 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -45,7 +45,7 @@ from app.main.validators import ( CommonlyUsedPassword, CsvFileValidator, DoesNotStartWithDoubleZero, - LettersNumbersFullStopsAndUnderscoresOnly, + LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly, MustContainAlphanumericCharacters, NoCommasInPlaceHolders, NoEmbeddedImagesInSVG, @@ -1734,7 +1734,7 @@ class ServiceSmsSenderForm(StripWhitespaceForm): DataRequired(message="Cannot be empty"), Length(max=11, message="Enter 11 characters or fewer"), Length(min=3, message="Enter 3 characters or more"), - LettersNumbersFullStopsAndUnderscoresOnly(), + LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly(), DoesNotStartWithDoubleZero(), ] ) diff --git a/app/main/validators.py b/app/main/validators.py index 9d09fbe0c..d3b267332 100644 --- a/app/main/validators.py +++ b/app/main/validators.py @@ -144,9 +144,9 @@ class BroadcastLength: ) -class LettersNumbersFullStopsAndUnderscoresOnly: +class LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly: - 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'): self.message = message diff --git a/tests/app/main/test_validators.py b/tests/app/main/test_validators.py index 21fd64692..9458dbd62 100644 --- a/tests/app/main/test_validators.py +++ b/tests/app/main/test_validators.py @@ -199,6 +199,7 @@ def test_if_string_contains_alphanumeric_characters_does_not_raise(string): ('00111222333', True, 'Cannot start with 00'), ('UK_GOV', False, None), # Underscores are allowed ('UK.GOV', False, None), # Full stops are allowed + ("'UC'", False, None), # Straight single quotes are allowed ] ) def test_sms_sender_form_validation(