mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Added custom field API tests
This commit is contained in:
@@ -32,6 +32,12 @@ class CustomFieldsSerializer(serializers.BaseSerializer):
|
||||
if parent_content_type not in cf.obj_type.all():
|
||||
raise ValidationError(u"Invalid custom field for {} objects".format(parent_content_type))
|
||||
|
||||
# Validate selected choice
|
||||
if cf.type == CF_TYPE_SELECT:
|
||||
valid_choices = [c.pk for c in cf.choices.all()]
|
||||
if value not in valid_choices:
|
||||
raise ValidationError(u"Invalid choice ({}) for field {}".format(value, custom_field))
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user