Validate name field on ServiceUpdateEmailBranding form

This introduces a validator to validate that the name field is not empty
on the ServiceUpdateEmailBranding form, but only if the form details are
being submitted. If a file is being uploaded, the name is allowed to be
empty.
This commit is contained in:
Katie Smith
2019-01-25 16:54:24 +00:00
parent 52acf890dd
commit 5b77329e63
3 changed files with 61 additions and 0 deletions

View File

@@ -848,6 +848,11 @@ class ServiceUpdateEmailBranding(StripWhitespaceForm):
]
)
def validate_name(form, name):
op = request.form.get('operation')
if op == 'email-branding-details' and not form.name.data:
raise ValidationError('This field is required')
class PDFUploadForm(StripWhitespaceForm):
file = FileField_wtf(