You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This way of formatting doesn't format %(value)s.
Thus the message "'%(value)s' value must be a positive integer or a valid Hashids string." is returned.
If the origial message were like "'{value}' value must be a positive integer or a valid Hashids string." for example, formatting functions well.
The text was updated successfully, but these errors were encountered:
Thank you for the detailed bug report, it made it very easy to see what you're talking about. I guess DRF changed the error formatting at some point, so I have updated to match. 3.3.5 released. Thanks!
Premise
Description
Hello.
When I pass invalid hashid str, 'foo' for example, HashidSerializerCharField returns a message below.
What I expect is below.
My serializer is defined like below.
Is there the best way to get a valid message?
What causes the problem
I researched what causes the problem. I hope it helps you.
The original message is defined here below.
https://github.com/nshafer/django-hashid-field/blob/master/hashid_field/rest.py#L24
When ValueError occurs, the invalid str is sent as 'value' to fail method.
https://github.com/nshafer/django-hashid-field/blob/master/hashid_field/rest.py#L65
Then it is expected that the message is going to be formatted like below.
Though it is formatted in the rest_framework actually like below.
https://github.com/encode/django-rest-framework/blob/master/rest_framework/fields.py#L642
This way of formatting doesn't format
%(value)s
.Thus the message "'%(value)s' value must be a positive integer or a valid Hashids string." is returned.
If the origial message were like
"'{value}' value must be a positive integer or a valid Hashids string."
for example, formatting functions well.The text was updated successfully, but these errors were encountered: