Updates to text area validation on template edit page

This commit is contained in:
Jonathan Bobel
2025-03-18 15:55:01 -04:00
parent bc83fab764
commit 1d911c4d44
3 changed files with 33 additions and 204 deletions

View File

@@ -108,32 +108,17 @@ class OnlySMSCharacters:
)
if non_sms_characters:
raise ValidationError(
"You cannot use {} in {}. {} will not show up properly on everyones phones.".format(
"Please remove the unaccepted character {} in your message, then save again".format(
formatted_list(
non_sms_characters,
conjunction="or",
conjunction="and",
before_each="",
after_each="",
),
{
"sms": "text messages",
}.get(self._template_type),
("It" if len(non_sms_characters) == 1 else "They"),
)
)
# class NoPlaceholders:
# def __init__(self, message=None):
# self.message = message or (
# 'You cant use ((double brackets)) to personalize this message'
# )
# def __call__(self, form, field):
# if Field(field.data).placeholders:
# raise ValidationError(self.message)
class LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly:
regex = re.compile(r"^[a-zA-Z0-9\s\._']+$")