I have a serializer that validates fields based on the values of other fields, In the error response I would like to show each field error as a field error as opposed to showing
If you have logic that applies to all the fields, you can still get the desired result by doing this:
def validate(self, data):
for key, value in data.items():
# checks if value is empty
if not value:
raise serializers.ValidationError({key: "This field should not be left empty."})
return data