mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 21:18:16 -06:00
Set max_length=2 on extra_choices items; remove custom validation logic
This commit is contained in:
parent
f1322c932d
commit
bb72af864b
@ -172,7 +172,12 @@ class CustomFieldChoiceSetSerializer(ValidatedModelSerializer):
|
||||
choices=CustomFieldChoiceSetBaseChoices,
|
||||
required=False
|
||||
)
|
||||
extra_choices = serializers.ListField(child=serializers.ListField(min_length=2))
|
||||
extra_choices = serializers.ListField(
|
||||
child=serializers.ListField(
|
||||
min_length=2,
|
||||
max_length=2
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = CustomFieldChoiceSet
|
||||
@ -181,15 +186,6 @@ class CustomFieldChoiceSetSerializer(ValidatedModelSerializer):
|
||||
'choices_count', 'created', 'last_updated',
|
||||
]
|
||||
|
||||
def validate_extra_choices(self, value):
|
||||
for choice in value:
|
||||
if isinstance(choice, list):
|
||||
if len(choice) < 2:
|
||||
raise serializers.ValidationError('Each choice must have 2 elements.')
|
||||
else:
|
||||
raise serializers.ValidationError('Extra choice must be a list of two elements.')
|
||||
return value
|
||||
|
||||
|
||||
#
|
||||
# Custom links
|
||||
|
Loading…
Reference in New Issue
Block a user