-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Pass the attribute name to the converter? (3 arg converters) #1108
Comments
I think this could be a useful feature. But I don't see another way than passing the attribute's name by hand. It should of course be possible to configure the converter callable to accept some parameters (if it doesn't work already, have you tried that?). |
What do you mean "by hand"? The validators are called with At the moment, only the |
I have started to work on three-arg converters before my vacation based on #404. But it’s a bit tricky to get it right without a performance penalty. |
3 arg converters would be great, I'm often wanting to write generic converters that know the type of the attribute they need to convert to |
This is not a bug per se but more an improvement.
From my understanding, converters are passed only the value today.
Would it be possible to pass the attribute name as well?
The motivation behind this is because as you try to convert/parse data in the converter, you end up adding some validation as well and it would be helpful to know for what attribute it is run for to have a better error message. (e.g.: f"{attribute} value cannot be converted to a date")
In the example below, the converter tries to convert the input into a date object.
This can fail and it would make sense to raise a validation error at that point but it would help to know the attribute this is for.
Thoughts?
The text was updated successfully, but these errors were encountered: