Skip to content

Minimal change required to show all validation errors for all required fields #7

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions drf_braces/serializers/form_serializer.py
Original file line number Diff line number Diff line change
@@ -41,9 +41,7 @@ def run_validation(self, data):
# Only handle a ValidationError if the full validation is
# requested or if field is in minimum required in the case
# of partial validation.
if any([not self.parent.partial,
self.parent.Meta.failure_mode == FormSerializerFailure.fail,
self.field_name in self.parent.Meta.minimum_required]):
if self.field_name in self.parent.Meta.minimum_required:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this help? the original conditions are more strict when validating fields

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it makes sense. you want to bypass the DRF field validations in order to force form validations to kick in. better place for that would be to add an option in the Meta which will force the serializer to not include any DRF fields and will force validation to happen in the form.

places to look in the code:

FormSerializerBase.get_fields
FormSerializerOptions

raise
raise serializers.SkipField