Users can set a value that appears as the sender of a text message.

It can be up to eleven characters alpha numeric, no special characters
allowed.
This commit is contained in:
Adam Shimali
2016-07-01 13:47:22 +01:00
parent facfb98bb3
commit 3bfcf0f8b3
8 changed files with 137 additions and 6 deletions

View File

@@ -12,7 +12,8 @@ from wtforms import (
FileField,
BooleanField,
HiddenField,
IntegerField)
IntegerField
)
from wtforms.fields.html5 import EmailField, TelField
from wtforms.validators import (DataRequired, Email, Length, Regexp)
@@ -318,3 +319,13 @@ class ProviderForm(Form):
class ServiceReplyToEmailFrom(Form):
email_address = email_address()
class ServiceSmsSender(Form):
sms_sender = StringField('', validators=[Length(max=11,
message="Text message sender can't be longer than 11 characters")])
def validate_sms_sender(form, field):
import re
if not re.match('^[a-zA-Z0-9\s]+$', field.data):
raise ValidationError('Sms text message sender can only contain alpha-numeric characters')