f"Value must be an id of an element in {select_options}",
)
elif field.data_type == CustomField.FieldDataType.DOCUMENTLINK:
+ if not (isinstance(data["value"], list) or data["value"] is None):
+ raise serializers.ValidationError(
+ "Value must be a list",
+ )
doc_ids = data["value"]
if Document.objects.filter(id__in=doc_ids).count() != len(
data["value"],
- Document & custom field exist
WHEN:
- API request to set a field value to a document that does not exist
+ - API request to set a field value to empty string
THEN:
- HTTP 400 is returned
- No field instance is created or attached to the document
self.assertEqual(CustomFieldInstance.objects.count(), 0)
self.assertEqual(len(doc.custom_fields.all()), 0)
+ resp = self.client.patch(
+ f"/api/documents/{doc.id}/",
+ data={
+ "custom_fields": [
+ {"field": custom_field_documentlink.id, "value": ""},
+ ],
+ },
+ format="json",
+ )
+
+ self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
+ self.assertEqual(CustomFieldInstance.objects.count(), 0)
+
def test_custom_field_not_null(self):
"""
GIVEN: