mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 14:38:25 -04:00
Merge pull request #1685 from alphagov/comma-error
Update error message about commas in placeholders
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
from wtforms import ValidationError
|
from wtforms import ValidationError
|
||||||
from notifications_utils.template import Template
|
from notifications_utils.field import Field
|
||||||
from notifications_utils.gsm import get_non_gsm_compatible_characters
|
from notifications_utils.gsm import get_non_gsm_compatible_characters
|
||||||
|
|
||||||
from app import formatted_list
|
from app import formatted_list
|
||||||
@@ -45,11 +45,11 @@ class ValidGovEmail:
|
|||||||
|
|
||||||
class NoCommasInPlaceHolders:
|
class NoCommasInPlaceHolders:
|
||||||
|
|
||||||
def __init__(self, message='You can’t have commas in your fields'):
|
def __init__(self, message='You can’t put commas between double brackets'):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
def __call__(self, form, field):
|
def __call__(self, form, field):
|
||||||
if ',' in ''.join(Template({'content': field.data}).placeholders):
|
if ',' in ''.join(Field(field.data).placeholders):
|
||||||
raise ValidationError(self.message)
|
raise ValidationError(self.message)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ def test_for_commas_in_placeholders(
|
|||||||
):
|
):
|
||||||
with pytest.raises(ValidationError) as error:
|
with pytest.raises(ValidationError) as error:
|
||||||
NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name,date))'))
|
NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name,date))'))
|
||||||
assert str(error.value) == 'You can’t have commas in your fields'
|
assert str(error.value) == 'You can’t put commas between double brackets'
|
||||||
NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name))'))
|
NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name))'))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user