New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validators do not implement __eq__
method
#8905
Comments
would you mind come with at least one draft implementation of this? I need to see what we can actually achieve with it. I can recall something like this in django core but can't remember exact usecases |
Implementation - It's in the core validators: https://github.com/django/django/blob/stable/4.2.x/django/core/validators.py#L57 A use case is to be able to test whether a validator appears in a serializer's list of validators. For example: For this to work lazy formatted validator messages would also need to implement
and
Serializer fields are difficult to test declaratively because of these omissions. I'm running into these issues while creating field asserts for my serializers like I use for my models.
How could anyone test their serializer field definitions declaratively w\o the |
as it is a django compat stuff, I am open to contribution in this regard |
So is this getting labeled as accepted and put on the todo pile? |
yes |
Rest Framework validators do not implement the
__eq__
method like many of their Django counterparts.The expression
ProhibitSurrogateCharactersValidator() == ProhibitSurrogateCharactersValidator()
evaluates toFalse
when it would be useful to have it evaluate toTrue
, especially in tests.The text was updated successfully, but these errors were encountered: