Sfoglia il codice sorgente

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

Daniel Sheppard 3 anni fa
parent
commit
c42f7ab6d3
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      netbox/utilities/forms/widgets.py

+ 7 - 0
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 []