Skip to content

Handle tuples same as lists in ValidationError detail context #7647

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

Merged
merged 3 commits into from
Jan 6, 2021

Conversation

seppeljordan
Copy link
Contributor

Description

This PR changes the behavior of ValidationError slightly. Previously when handling details passed into the constructor, e.g. `ValidationError(detail=('message1', 'message2')) tuples got converted to strings. This means that the resulting JSON in the response looked similar to

"error": "('message1', 'message2')"

instead of

"error": ["message1", "message2"]

which one might expect.

The described behavior might be unintuitive users. This is why after this PR would be merged, tuples would get the same treatment as lists in this regard, ergo result in outcome 2 instead of 1.

@seppeljordan seppeljordan force-pushed the error-details-tuple branch 2 times, most recently from 001f312 to 95ba2ac Compare November 23, 2020 09:33
@seppeljordan
Copy link
Contributor Author

Hi, can I do anything from my side to accelerate the review process?

@seppeljordan
Copy link
Contributor Author

@tomchristie @xordoquy Hi, is this wanted? Please let me know.

@tomchristie
Copy link
Member

tomchristie commented Jan 6, 2021

Looks reasonable to me, yup.

Thanks!

@tomchristie tomchristie merged commit 19655ed into encode:master Jan 6, 2021
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants