Validate recipients in send a one-off message

It would be annoying to get all the way to the end of the flow and get
told that the phone number or email address you entered isn’t valid.

So this commit reuses the existing WTForms objects that we have to do
some extra validation on the first step in the send one-off message
flow. It also accounts for international phone numbers, if the service
is allowed to send them.

It doesn’t reject other people’s phone numbers if your service is
restricted, because I think it’s better to let users play with the
feature – it’s good for learning.
This commit is contained in:
Chris Hill-Scott
2017-05-25 09:40:37 +01:00
parent 7310e8b435
commit 27c1463213
3 changed files with 79 additions and 8 deletions

View File

@@ -245,6 +245,7 @@ def send_test_step(service_id, template_id, step_index):
current_placeholder,
dict_to_populate_from=get_normalised_send_test_values_from_session(),
optional_placeholder=optional_placeholder,
allow_international_phone_numbers=current_service['can_send_international_sms'],
)
if form.validate_on_submit():