creating custom validators for fields in Django REST framework serializers.Serializer
I am writing a serializer for a complicated put
API with a large validate function. To simplify the logic and make it more readable, I want to create validators for individual fields (I want to make my serializer class as small as possible and hence don’t want to write individual validate
methods for each field). I am passing context to my serializer from the view and each of my fields share a common context. I want to use that context in the validator to perform the required checks.