title: How do I use a custom class based validator for multiple fields in Django Rest Framework?
body: <p>I need to validate a field depending on another field with multiple validators like so:</p>
  <pre class="lang-py prettyprint-override"><code>logged_in_id = serializers.UUIDField(validators=[Internal() | LoggedIn()])
  </code></pre>
  <p>where <code>Internal</code> and <code>LoggedIn</code> are class based validators:</p>
  <pre><code>class LoggedIn:
      def __call__(self, value):
          if other_id == value:  # other_id is another field like logged_in_id
              return True
          return False
  </code></pre>
  <p>Can I access the <code>validated_data</code> of the serializer in a validator class somehow? Or write a validator class not for a specific field, but for the whole serializer, like the <code>validate</code> function?</p>
  <p>Docs: <a href="https://www.django-rest-framework.org/api-guide/validators/" rel="nofollow noreferrer">https://www.django-rest-framework.org/api-guide/validators/</a></p>