Add postcode validation check for one-off letters

We’re doing this everywhere else now, so this completes the story.

It uses the same regex as elsewhere and the error messaging is
consistent (but not uniform) with the other places.
This commit is contained in:
Chris Hill-Scott
2020-04-02 17:32:26 +01:00
parent 26f702ebce
commit c646c16067
2 changed files with 16 additions and 10 deletions

View File

@@ -769,6 +769,11 @@ class LetterAddressForm(StripWhitespaceForm):
f'Address must be no more than {PostalAddress.MAX_LINES} lines long'
)
if not address.postcode:
raise ValidationError(
f'Last line of the address must be a real UK postcode'
)
class EmailTemplateForm(BaseTemplateForm):
subject = TextAreaField(