From c42f7ab6d36ed87844372c6bfd9883aa28e01e24 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Fri, 2 Sep 2022 13:48:15 -0500 Subject: [PATCH 1/2] Fixes #9823 - Make validation error from NumericArrayField more verbose. --- netbox/utilities/forms/widgets.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/netbox/utilities/forms/widgets.py b/netbox/utilities/forms/widgets.py index c27f3c646..429a111b3 100644 --- a/netbox/utilities/forms/widgets.py +++ b/netbox/utilities/forms/widgets.py @@ -110,6 +110,13 @@ 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 [] From 25a474f9f7950a11b45d78f99539a238845f58f9 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Fri, 2 Sep 2022 14:05:38 -0500 Subject: [PATCH 2/2] Fix PEP8 errors --- netbox/utilities/forms/widgets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/netbox/utilities/forms/widgets.py b/netbox/utilities/forms/widgets.py index 429a111b3..76a4bc607 100644 --- a/netbox/utilities/forms/widgets.py +++ b/netbox/utilities/forms/widgets.py @@ -116,7 +116,6 @@ class NumericArrayField(SimpleArrayField): f'Must be numeric and ranges must be in ascending order') return super().clean(value) - def to_python(self, value): if not value: return []