mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-24 23:19:47 +03:00
Fixes #8716 (adds OverflowError
to FloatField
This commit is contained in:
parent
2510456817
commit
f6490dc909
|
@ -945,6 +945,8 @@ class FloatField(Field):
|
||||||
return float(data)
|
return float(data)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
self.fail('invalid')
|
self.fail('invalid')
|
||||||
|
except OverflowError:
|
||||||
|
self.fail('overflow')
|
||||||
|
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
return float(value)
|
return float(value)
|
||||||
|
@ -953,6 +955,7 @@ class FloatField(Field):
|
||||||
class DecimalField(Field):
|
class DecimalField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('A valid number is required.'),
|
'invalid': _('A valid number is required.'),
|
||||||
|
'overflow': _('Integer value too large.'),
|
||||||
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
|
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
|
||||||
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
|
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
|
||||||
'max_digits': _('Ensure that there are no more than {max_digits} digits in total.'),
|
'max_digits': _('Ensure that there are no more than {max_digits} digits in total.'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user