mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 11:56:25 -06:00
Update validation to model clean method instead of serializer
This commit is contained in:
parent
d4c8e88fd7
commit
bab5a5b273
@ -247,13 +247,6 @@ class InterfaceSerializer(NetBoxModelSerializer, CabledObjectSerializer, Connect
|
||||
f"or it must be global."
|
||||
})
|
||||
|
||||
# Validate that tagged-all payload does not include tagged_vlans
|
||||
mode = data.get('mode') or getattr(self.instance, 'mode', None)
|
||||
if mode == InterfaceModeChoices.MODE_TAGGED_ALL and data.get('tagged_vlans'):
|
||||
raise serializers.ValidationError({
|
||||
'tagged_vlans': "Tagged-All interface mode must not include any tagged vlans"
|
||||
})
|
||||
|
||||
return super().validate(data)
|
||||
|
||||
|
||||
|
@ -904,6 +904,12 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
|
||||
).format(untagged_vlan=self.untagged_vlan)
|
||||
})
|
||||
|
||||
# Validate that tagged-all payload does not include tagged_vlans
|
||||
if self.mode != InterfaceModeChoices.MODE_TAGGED and self.tagged_vlans:
|
||||
raise ValidationError({
|
||||
'tagged_vlans': "Interface mode does not support including tagged vlans"
|
||||
})
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
# Set absolute channel attributes from selected options
|
||||
|
Loading…
Reference in New Issue
Block a user