Merge pull request #10253 from netbox-community/9823-fix_numericarrayfield_validation_error

Fixes #9823 - Make validation error from NumericArrayField more verbose.
This commit is contained in:
Jeremy Stretch 2022-09-02 15:18:42 -04:00 committed by GitHub
commit 572803d7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,6 +110,12 @@ class SelectSpeedWidget(forms.NumberInput):
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):
if not value:
return []