BaseForms validation and ValidationError's params
|Reported by:||cgenie@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In forms/forms.py the _clean_fields function of BaseForm waits for ValidationError exception and inserts e.messages to self._errors.
The problem is that ValidationError supports quite useful things, like params, understanding dict arguments, etc. Since forms/forms.py takes only e.messages, there's no way to access later these parameters.
Would this make a reasonable request for improvement of BaseForms: instead of using e.messages, wrap the returned exception into some object, whose unicode method returns e.messages (to preserve compatibility), with additional properties taken from ValidationError.params?
This would allow for fine-grained error reporting. Not only would we have error messages reported per field, but could also specify additional parameters in the error message.
Change History (5)
comment:1 Changed 2 years ago by akaariai
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Resolution set to wontfix
- Status changed from new to closed
comment:2 Changed 2 years ago by ko.szymanski@…
- Resolution wontfix deleted
- Status changed from closed to new