Fixes #9823 - Make validation error from NumericArrayField more verbose.

This commit is contained in:
Daniel Sheppard 2022-09-02 13:48:15 -05:00
parent a7717b432e
commit c42f7ab6d3
No known key found for this signature in database
GPG Key ID: A14DEAB809B8E077

View File

@ -110,6 +110,13 @@ class SelectSpeedWidget(forms.NumberInput):
class NumericArrayField(SimpleArrayField): class NumericArrayField(SimpleArrayField):
def clean(self, value):
if value and not self.to_python(value):
raise forms.ValidationError(f'Invalid list ({value}). '
f'Must be numeric and ranges must be in ascending order')
return super().clean(value)
def to_python(self, value): def to_python(self, value):
if not value: if not value:
return [] return []