-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Don't format error messages on validators #3407
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
Conversation
Couple of things here:
|
Good catch, however, when I remove this from the
Do you mean something along the lines of?: self.validators.append(MaxLengthValidator(self.max_length, message=self.message)) |
That's what I was thinking - tho let's look to Django's Field classes for direction. |
Looking at both Django's |
encode#3354 - Update tests to reflect new error messages provided by Django field parent classes
db16728
to
2cd4162
Compare
OK @tomchristie, I followed Django's |
TNL-3373 Django REST Framework has a pull request to fix this problem: encode/django-rest-framework#3407 We want it now, though, so I picked it onto their tip in my own fork. Once they merge it and release, we can put this back to an official release.
@nryoung I'm not sure your last commit what was we had in mind. Can't we instead simply pass the unformatted message to the Validator and be using the Validation's formatters instead of the current format ? |
ie:
would become:
|
@xordoquy understood. I misunderstood what @tomchristie was asking for. I can probably get this fixed up tomorrow. |
@tomchristie I don't think so. In my snippet it should defer the format to the moment the validation is performed which should fix the initial issue. |
Okay, so how would you rephrase it without bringing in the (unrelated) pluralization issue. The problem is that the lazy translation is being evaluated at the point that we format it, no? |
@tomchristie it's a bit more complex than it appears. Will open a new PR a bit later. |
Closing this off as stale. |
In refs to: #3354
This removes
.format
calls on error messages and defaults to using the default class attribute error message.