-
+
@if (hint) {
}
diff --git a/src-ui/src/app/components/common/input/text/text.component.ts b/src-ui/src/app/components/common/input/text/text.component.ts
index a546e2e39..594f5f1d6 100644
--- a/src-ui/src/app/components/common/input/text/text.component.ts
+++ b/src-ui/src/app/components/common/input/text/text.component.ts
@@ -18,6 +18,9 @@ export class TextComponent extends AbstractInputComponent
{
@Input()
autocomplete: string
+ @Input()
+ placeholder: string = ''
+
constructor() {
super()
}
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html
index 84ab680b1..124f4811d 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.html
+++ b/src-ui/src/app/components/document-detail/document-detail.component.html
@@ -157,6 +157,7 @@
@case (CustomFieldDataType.Monetary) {
0
+ and len(attrs["extra_data"]["default_currency"]) != 3
+ )
+ )
+ ):
+ raise serializers.ValidationError(
+ {"error": "extra_data.default_currency must be a 3-character string"},
+ )
return super().validate(attrs)
diff --git a/src/documents/tests/test_api_custom_fields.py b/src/documents/tests/test_api_custom_fields.py
index edebf7f3c..6ffe14681 100644
--- a/src/documents/tests/test_api_custom_fields.py
+++ b/src/documents/tests/test_api_custom_fields.py
@@ -137,6 +137,66 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase):
)
self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
+ def test_create_custom_field_monetary_validation(self):
+ """
+ GIVEN:
+ - Custom field does not exist
+ WHEN:
+ - API request to create custom field with invalid default currency option
+ - API request to create custom field with valid default currency option
+ THEN:
+ - HTTP 400 is returned
+ - HTTP 201 is returned
+ """
+
+ # not a string
+ resp = self.client.post(
+ self.ENDPOINT,
+ json.dumps(
+ {
+ "data_type": "monetary",
+ "name": "Monetary Field",
+ "extra_data": {
+ "default_currency": 123,
+ },
+ },
+ ),
+ content_type="application/json",
+ )
+ self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
+
+ # not a 3-letter currency code
+ resp = self.client.post(
+ self.ENDPOINT,
+ json.dumps(
+ {
+ "data_type": "monetary",
+ "name": "Monetary Field",
+ "extra_data": {
+ "default_currency": "EU",
+ },
+ },
+ ),
+ content_type="application/json",
+ )
+ self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
+
+ # valid currency code
+ resp = self.client.post(
+ self.ENDPOINT,
+ json.dumps(
+ {
+ "data_type": "monetary",
+ "name": "Monetary Field",
+ "extra_data": {
+ "default_currency": "EUR",
+ },
+ },
+ ),
+ content_type="application/json",
+ )
+ self.assertEqual(resp.status_code, status.HTTP_201_CREATED)
+
def test_create_custom_field_instance(self):
"""
GIVEN: