diff --git a/netbox/dcim/api/serializers_/device_components.py b/netbox/dcim/api/serializers_/device_components.py index fd66f0a1f..d342a8c49 100644 --- a/netbox/dcim/api/serializers_/device_components.py +++ b/netbox/dcim/api/serializers_/device_components.py @@ -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) diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index a785d5db1..88270bd85 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -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