make UniqueTogetherValidator generic #8232
Unanswered
abtinmo
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
considering this following models:
by default message for ValidationError in our ModelSerializer would be:
The fields title, author must make a unique set.
which in our case make no sense and better message would be:
Title must be unique.
current solution is to define validator in meta class and there write more meaningful message, so you need to define validator for every serializer, it means more code to write and maintain
I'm suggesting to use UniqueTogetherValidator through settings and DEFAULT_UNIQUE_TOGETHER_VALIDATOR_CLASS, this way developers could override default class and change the response for all of their UniqueTogether validations, other use would be returning exact field name(title in my example) instead of non_field_errors
Beta Was this translation helpful? Give feedback.
All reactions