Refs #29131 -- Fixed space handling in ArrayField's item_invalid message.

This commit is contained in:
Hasan Ramezani 2018-05-14 02:27:28 +04:30 committed by Tim Graham
parent 2405833c53
commit 31ce1f7433
3 changed files with 4 additions and 4 deletions

View File

@ -19,7 +19,7 @@ __all__ = ['ArrayField']
class ArrayField(CheckFieldDefaultMixin, Field): class ArrayField(CheckFieldDefaultMixin, Field):
empty_strings_allowed = False empty_strings_allowed = False
default_error_messages = { default_error_messages = {
'item_invalid': _('Item %(nth)s in the array did not validate: '), 'item_invalid': _('Item %(nth)s in the array did not validate:'),
'nested_array_mismatch': _('Nested arrays must have the same length.'), 'nested_array_mismatch': _('Nested arrays must have the same length.'),
} }
_default_hint = ('list', '[]') _default_hint = ('list', '[]')

View File

@ -13,7 +13,7 @@ from ..utils import prefix_validation_error
class SimpleArrayField(forms.CharField): class SimpleArrayField(forms.CharField):
default_error_messages = { default_error_messages = {
'item_invalid': _('Item %(nth)s in the array did not validate: '), 'item_invalid': _('Item %(nth)s in the array did not validate:'),
} }
def __init__(self, base_field, *, delimiter=',', max_length=None, min_length=None, **kwargs): def __init__(self, base_field, *, delimiter=',', max_length=None, min_length=None, **kwargs):
@ -167,7 +167,7 @@ class SplitArrayWidget(forms.Widget):
class SplitArrayField(forms.Field): class SplitArrayField(forms.Field):
default_error_messages = { default_error_messages = {
'item_invalid': _('Item %(nth)s in the array did not validate: '), 'item_invalid': _('Item %(nth)s in the array did not validate:'),
} }
def __init__(self, base_field, size, *, remove_trailing_nulls=False, **kwargs): def __init__(self, base_field, size, *, remove_trailing_nulls=False, **kwargs):

View File

@ -17,7 +17,7 @@ def prefix_validation_error(error, prefix, code, params):
# ngettext calls require a count parameter and are converted # ngettext calls require a count parameter and are converted
# to an empty string if they are missing it. # to an empty string if they are missing it.
message=format_lazy( message=format_lazy(
'{}{}', '{} {}',
SimpleLazyObject(lambda: prefix % params), SimpleLazyObject(lambda: prefix % params),
SimpleLazyObject(lambda: error.message % error_params), SimpleLazyObject(lambda: error.message % error_params),
), ),