|
@@ -606,5 +606,18 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
|
|
|
f"Invalid choice(s) ({', '.join(value)}). Available choices are: {', '.join(self.choices)}"
|
|
f"Invalid choice(s) ({', '.join(value)}). Available choices are: {', '.join(self.choices)}"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ # Validate selected object
|
|
|
|
|
+ elif self.type == CustomFieldTypeChoices.TYPE_OBJECT:
|
|
|
|
|
+ if type(value) is not int:
|
|
|
|
|
+ raise ValidationError(f"Value must be an object ID, not {type(value).__name__}")
|
|
|
|
|
+
|
|
|
|
|
+ # Validate selected objects
|
|
|
|
|
+ elif self.type == CustomFieldTypeChoices.TYPE_MULTIOBJECT:
|
|
|
|
|
+ if type(value) is not list:
|
|
|
|
|
+ raise ValidationError(f"Value must be a list of object IDs, not {type(value).__name__}")
|
|
|
|
|
+ for id in value:
|
|
|
|
|
+ if type(id) is not int:
|
|
|
|
|
+ raise ValidationError(f"Found invalid object ID: {id}")
|
|
|
|
|
+
|
|
|
elif self.required:
|
|
elif self.required:
|
|
|
raise ValidationError("Required field cannot be empty.")
|
|
raise ValidationError("Required field cannot be empty.")
|