limit matching options in serializer

[ci skip]
This commit is contained in:
shamoon 2025-03-20 21:53:58 -07:00
parent 8a907c2868
commit dbe58672ed
No known key found for this signature in database

@ -670,6 +670,19 @@ class CustomFieldSerializer(MatchingModelSerializer, serializers.ModelSerializer
raise serializers.ValidationError(
{"error": "extra_data.default_currency must be a 3-character string"},
)
if (
"matching_algorithm" in attrs
and attrs["matching_algorithm"] != CustomField.MATCH_REGEX
and "data_type" in attrs
and attrs["data_type"]
not in [
CustomField.FieldDataType.SELECT,
CustomField.FieldDataType.BOOL,
]
):
raise serializers.ValidationError(
{"error": "Only discrete data types support matching"},
)
return super().validate(attrs)
def to_internal_value(self, data):