mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Merge fbb74e7a40
into 0b864acd98
This commit is contained in:
commit
d631d74141
|
@ -552,7 +552,7 @@ class ChoiceField(WritableField):
|
||||||
Validates that the input is in self.choices.
|
Validates that the input is in self.choices.
|
||||||
"""
|
"""
|
||||||
super(ChoiceField, self).validate(value)
|
super(ChoiceField, self).validate(value)
|
||||||
if value and not self.valid_value(value):
|
if value not in validators.EMPTY_VALUES and not self.valid_value(value):
|
||||||
raise ValidationError(self.error_messages['invalid_choice'] % {'value': value})
|
raise ValidationError(self.error_messages['invalid_choice'] % {'value': value})
|
||||||
|
|
||||||
def valid_value(self, value):
|
def valid_value(self, value):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user