Removed redundant forms.DecimalField.validate() in favor of DecimalValidator.

This commit is contained in:
Jon Dufresne 2020-07-26 19:18:59 -07:00 committed by Mariusz Felisiak
parent f4e93919e4
commit cc3d24d7d5
2 changed files with 1 additions and 8 deletions

View File

@ -438,7 +438,7 @@ class DecimalValidator:
def __call__(self, value):
digit_tuple, exponent = value.as_tuple()[1:]
if exponent in {'F', 'n', 'N'}:
raise ValidationError(self.messages['invalid'])
raise ValidationError(self.messages['invalid'], code='invalid')
if exponent >= 0:
# A positive exponent adds that many trailing zeros.
digits = len(digit_tuple) + exponent

View File

@ -350,13 +350,6 @@ class DecimalField(IntegerField):
raise ValidationError(self.error_messages['invalid'], code='invalid')
return value
def validate(self, value):
super().validate(value)
if value in self.empty_values:
return
if not value.is_finite():
raise ValidationError(self.error_messages['invalid'], code='invalid')
def widget_attrs(self, widget):
attrs = super().widget_attrs(widget)
if isinstance(widget, NumberInput) and 'step' not in widget.attrs: