diff --git a/radis/reports/api/serializers.py b/radis/reports/api/serializers.py index 63b35ee4..dd82aed4 100644 --- a/radis/reports/api/serializers.py +++ b/radis/reports/api/serializers.py @@ -136,3 +136,10 @@ def to_representation(self, instance: Any) -> Any: ret["modalities"] = [item["code"] for item in ret["modalities"]] return ret + + def validate(self, attrs: Any) -> Any: + if hasattr(self, "initial_data"): + unknown_keys = set(self.initial_data.keys()) - set(self.fields.keys()) + if unknown_keys: + raise ValidationError("Got unknown fields: {}".format(unknown_keys)) + return super().validate(attrs)