mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
9627 update validation
This commit is contained in:
parent
226312631a
commit
1560fff2af
@ -98,7 +98,13 @@ class VLANGroup(OrganizationalModel):
|
||||
|
||||
# Validate vlan ranges
|
||||
if check_ranges_overlap(self.vlan_id_ranges):
|
||||
raise ValidationError(_("Ranges cannot overlap."))
|
||||
raise ValidationError({'vlan_id_ranges': _("Ranges cannot overlap.")})
|
||||
|
||||
for ranges in self.vlan_id_ranges:
|
||||
if ranges.lower >= ranges.upper:
|
||||
raise ValidationError({
|
||||
'vlan_id_ranges': _("Maximum child VID must be greater than or equal to minimum child VID Invalid range ({value})").format(value=ranges)
|
||||
})
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self._total_vlan_ids = 0
|
||||
|
@ -140,6 +140,9 @@ def ranges_to_string(ranges):
|
||||
For example:
|
||||
[1-100, 200-300] => "1-100, 200-300"
|
||||
"""
|
||||
if not ranges:
|
||||
return ""
|
||||
|
||||
return ', '.join([f"{val.lower}-{val.upper}" for val in ranges])
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user