From cc3d24d7d577f174937a0744d886c4c7123cfa85 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 26 Jul 2020 19:18:59 -0700 Subject: [PATCH] Removed redundant forms.DecimalField.validate() in favor of DecimalValidator. --- django/core/validators.py | 2 +- django/forms/fields.py | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/django/core/validators.py b/django/core/validators.py index 84b4f31ec7..a9b8855d0e 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -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 diff --git a/django/forms/fields.py b/django/forms/fields.py index 36dad72704..9de2c60b35 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -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: