Add object_type validation
This commit is contained in:
parent
1e80cc6db5
commit
bfc695434c
|
|
@ -242,6 +242,17 @@ class CustomField(ChangeLoggedModel):
|
||||||
'default': f"The specified default value ({self.default}) is not listed as an available choice."
|
'default': f"The specified default value ({self.default}) is not listed as an available choice."
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Object fields must define an object_type; other fields must not
|
||||||
|
if self.type in (CustomFieldTypeChoices.TYPE_OBJECT, CustomFieldTypeChoices.TYPE_MULTIOBJECT):
|
||||||
|
if not self.object_type:
|
||||||
|
raise ValidationError({
|
||||||
|
'object_type': "Object fields must define an object type."
|
||||||
|
})
|
||||||
|
elif self.object_type:
|
||||||
|
raise ValidationError({
|
||||||
|
'object_type': f"{self.get_type_display()} fields may not define an object type."
|
||||||
|
})
|
||||||
|
|
||||||
def serialize(self, value):
|
def serialize(self, value):
|
||||||
"""
|
"""
|
||||||
Prepare a value for storage as JSON data.
|
Prepare a value for storage as JSON data.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue