mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
Start allowing any three lines in addresses
This is part of moving away from `postcode` and towards `address line 7` We think it will be easier for people to map their existing data to our API if we let them fill in any 3 lines, instead of requiring at least 1, 2, and postcode specifically.
This commit is contained in:
@@ -348,8 +348,22 @@ def process_letter_notification(*, letter_data, api_key, template, reply_to_text
|
||||
template=template,
|
||||
reply_to_text=reply_to_text)
|
||||
|
||||
if not PostalAddress.from_personalisation(letter_data['personalisation']).postcode:
|
||||
raise ValidationError(message='Must be a real UK postcode')
|
||||
address = PostalAddress.from_personalisation(letter_data['personalisation'])
|
||||
|
||||
if not address.has_enough_lines:
|
||||
raise ValidationError(
|
||||
message=f'Address must be at least {PostalAddress.MIN_LINES} lines'
|
||||
)
|
||||
|
||||
if address.has_too_many_lines:
|
||||
raise ValidationError(
|
||||
message=f'Address must be no more than {PostalAddress.MAX_LINES} lines'
|
||||
)
|
||||
|
||||
if not address.postcode:
|
||||
raise ValidationError(
|
||||
message='Must be a real UK postcode'
|
||||
)
|
||||
|
||||
test_key = api_key.key_type == KEY_TYPE_TEST
|
||||
|
||||
|
||||
Reference in New Issue
Block a user