-
Notifications
You must be signed in to change notification settings - Fork 765
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
Add support for validation error codes #702
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #702 +/- ##
========================================
Coverage 98.13% 98.13%
========================================
Files 15 15
Lines 1123 1123
========================================
Hits 1102 1102
Misses 21 21
Continue to review full report at Codecov.
|
I'm currently stuck on this. I'm 95% sure there's a bug preventing DRF I need to look into this further. |
Note to self... |
return ValidationError(OrderedDict([ | ||
(key, [e.message for e in error_list]) | ||
for key, error_list in error.error_dict.items() | ||
])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to keep codes here:
error_dict = OrderedDict([
(key, [exceptions.ErrorDetail(e.message,
e.code if e.code else default_code)
for e in error_list])
for key, error_list in error_dict.items()])
drf_validation_error = exceptions.ValidationError(error_dict)
See encode/django-rest-framework#4787 (comment) for an updated version that also handles params. |
b493d83
to
bd180fe
Compare
I'm closing this off in favor of #788, which is generally reworking filterset validation. |
This is for both the base
FilterSet
and the DRF variant.FilterSet
is slightly broken, since it simply raisesValidationError(self.form.errors)
. This loses the individual validation error codes.raw_validation
approach needs to be modified to return an actualserializers.ValidationError
, since the plain data structure lacks the error codes.(This is WIP)