diff --git a/src/pretix/control/forms/vouchers.py b/src/pretix/control/forms/vouchers.py index 1bcbfaa48..95cdefd39 100644 --- a/src/pretix/control/forms/vouchers.py +++ b/src/pretix/control/forms/vouchers.py @@ -395,6 +395,15 @@ class VoucherBulkForm(VoucherForm): codes_seen = set() for c in data['codes']: + if len(c) < 5: + raise ValidationError({ + 'codes': [ + _('The voucher code {code} ist too short. Make sure all voucher codes are at least {min_length} characters long.').format( + code=c, + min_length=5 + ) + ] + }) if c in codes_seen: raise ValidationError(_('The voucher code {code} appears in your list twice.').format(code=c)) codes_seen.add(c) diff --git a/src/tests/control/test_vouchers.py b/src/tests/control/test_vouchers.py index 3b50017db..b2fe0c279 100644 --- a/src/tests/control/test_vouchers.py +++ b/src/tests/control/test_vouchers.py @@ -477,6 +477,10 @@ class VoucherFormTest(SoupTestMixin, TransactionTestCase): self._create_bulk_vouchers({ 'codes': 'ABCDE\nDEFGH\nIJKLM\nNOPQR\nSTUVW\nXYZ', 'itemvar': '%d' % self.ticket.pk, + }, expected_failure=True) + self._create_bulk_vouchers({ + 'codes': 'ABCDE\nDEFGH\nIJKLM\nNOPQR\nSTUVW', + 'itemvar': '%d' % self.ticket.pk, }) def test_create_blocking_bulk_quota_full(self):