Removed redundant forms.DecimalField.validate() in favor of DecimalValidator.
This commit is contained in:
parent
f4e93919e4
commit
cc3d24d7d5
|
@ -438,7 +438,7 @@ class DecimalValidator:
|
||||||
def __call__(self, value):
|
def __call__(self, value):
|
||||||
digit_tuple, exponent = value.as_tuple()[1:]
|
digit_tuple, exponent = value.as_tuple()[1:]
|
||||||
if exponent in {'F', 'n', 'N'}:
|
if exponent in {'F', 'n', 'N'}:
|
||||||
raise ValidationError(self.messages['invalid'])
|
raise ValidationError(self.messages['invalid'], code='invalid')
|
||||||
if exponent >= 0:
|
if exponent >= 0:
|
||||||
# A positive exponent adds that many trailing zeros.
|
# A positive exponent adds that many trailing zeros.
|
||||||
digits = len(digit_tuple) + exponent
|
digits = len(digit_tuple) + exponent
|
||||||
|
|
|
@ -350,13 +350,6 @@ class DecimalField(IntegerField):
|
||||||
raise ValidationError(self.error_messages['invalid'], code='invalid')
|
raise ValidationError(self.error_messages['invalid'], code='invalid')
|
||||||
return value
|
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):
|
def widget_attrs(self, widget):
|
||||||
attrs = super().widget_attrs(widget)
|
attrs = super().widget_attrs(widget)
|
||||||
if isinstance(widget, NumberInput) and 'step' not in widget.attrs:
|
if isinstance(widget, NumberInput) and 'step' not in widget.attrs:
|
||||||
|
|
Loading…
Reference in New Issue