Skip to content

Conversation

@LilyFirefly
Copy link

Fixes #2168.

Copy link
Author

Choose a reason for hiding this comment

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

This is a large copy/paste from Serializer.run_validation. I would prefer to refactor this to be more DRY, but I'm not sure how best to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we dropped the ValidationError and DjangoValidationError handling code into a function that takes an exception and returns the details for ValidationError to be raised, we could have that just in once place, which would be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could also consider pushing this... https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/fields.py#L307-L320 into a validate_empty_vaues

Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably recommend we drop the call to super here, in the same way we do for Serializer. It gets pretty confusing otherwise. This'd also let us move the if not isinstance(data, list) check out of to_internal_value which would be nicer and would mirror the Serializer classes if not isinstance(data, dict) check that occurs.

@lovelydinosaur
Copy link
Contributor

Going to take a look at some of this now based on your input.

@LilyFirefly LilyFirefly deleted the list-serializer-validate branch December 8, 2014 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ListSerializer.validate()

2 participants