mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-07 07:03:12 +03:00
Removed input value from deault_error_message (#5881)
This commit is contained in:
parent
4260531b6c
commit
7d64b7016d
|
@ -642,7 +642,7 @@ class Field(object):
|
||||||
|
|
||||||
class BooleanField(Field):
|
class BooleanField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('"{input}" is not a valid boolean.')
|
'invalid': _('Must be a valid boolean.')
|
||||||
}
|
}
|
||||||
default_empty_html = False
|
default_empty_html = False
|
||||||
initial = False
|
initial = False
|
||||||
|
@ -687,7 +687,7 @@ class BooleanField(Field):
|
||||||
|
|
||||||
class NullBooleanField(Field):
|
class NullBooleanField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('"{input}" is not a valid boolean.')
|
'invalid': _('Must be a valid boolean.')
|
||||||
}
|
}
|
||||||
initial = None
|
initial = None
|
||||||
TRUE_VALUES = {
|
TRUE_VALUES = {
|
||||||
|
@ -841,7 +841,7 @@ class UUIDField(Field):
|
||||||
valid_formats = ('hex_verbose', 'hex', 'int', 'urn')
|
valid_formats = ('hex_verbose', 'hex', 'int', 'urn')
|
||||||
|
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('"{value}" is not a valid UUID.'),
|
'invalid': _('Must be a valid UUID.'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
|
@ -629,7 +629,7 @@ class TestBooleanField(FieldValues):
|
||||||
False: False,
|
False: False,
|
||||||
}
|
}
|
||||||
invalid_inputs = {
|
invalid_inputs = {
|
||||||
'foo': ['"foo" is not a valid boolean.'],
|
'foo': ['Must be a valid boolean.'],
|
||||||
None: ['This field may not be null.']
|
None: ['This field may not be null.']
|
||||||
}
|
}
|
||||||
outputs = {
|
outputs = {
|
||||||
|
@ -654,7 +654,7 @@ class TestBooleanField(FieldValues):
|
||||||
for input_value in inputs:
|
for input_value in inputs:
|
||||||
with pytest.raises(serializers.ValidationError) as exc_info:
|
with pytest.raises(serializers.ValidationError) as exc_info:
|
||||||
field.run_validation(input_value)
|
field.run_validation(input_value)
|
||||||
expected = ['"{0}" is not a valid boolean.'.format(input_value)]
|
expected = ['Must be a valid boolean.'.format(input_value)]
|
||||||
assert exc_info.value.detail == expected
|
assert exc_info.value.detail == expected
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ class TestNullBooleanField(TestBooleanField):
|
||||||
None: None
|
None: None
|
||||||
}
|
}
|
||||||
invalid_inputs = {
|
invalid_inputs = {
|
||||||
'foo': ['"foo" is not a valid boolean.'],
|
'foo': ['Must be a valid boolean.'],
|
||||||
}
|
}
|
||||||
outputs = {
|
outputs = {
|
||||||
'true': True,
|
'true': True,
|
||||||
|
@ -815,8 +815,8 @@ class TestUUIDField(FieldValues):
|
||||||
284758210125106368185219588917561929842: uuid.UUID('d63a6fb6-88d5-40c7-a91c-9edf73283072')
|
284758210125106368185219588917561929842: uuid.UUID('d63a6fb6-88d5-40c7-a91c-9edf73283072')
|
||||||
}
|
}
|
||||||
invalid_inputs = {
|
invalid_inputs = {
|
||||||
'825d7aeb-05a9-45b5-a5b7': ['"825d7aeb-05a9-45b5-a5b7" is not a valid UUID.'],
|
'825d7aeb-05a9-45b5-a5b7': ['Must be a valid UUID.'],
|
||||||
(1, 2, 3): ['"(1, 2, 3)" is not a valid UUID.']
|
(1, 2, 3): ['Must be a valid UUID.']
|
||||||
}
|
}
|
||||||
outputs = {
|
outputs = {
|
||||||
uuid.UUID('825d7aeb-05a9-45b5-a5b7-05df87923cda'): '825d7aeb-05a9-45b5-a5b7-05df87923cda'
|
uuid.UUID('825d7aeb-05a9-45b5-a5b7-05df87923cda'): '825d7aeb-05a9-45b5-a5b7-05df87923cda'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user