Previously an extra list wrapped nested validation errors raised from serializer's validate() methods.
That was inconsistent with the format of validation errors raised by validate_<fieldname> methods.
i.e. these two resulted in *different* behaviour:
def validate_foo(self):
raise ValidationError(['bar'])
def validate(self):
raise ValidationError({'foo': ['bar']})
These two tests were previously added in
7d79cf35b7
but we have now discovered that there are not actually two separate
cases, there was just a bug in the code that made it look that way.
This also removes a redundant check to see if `DecimalValidator` was
defined.
All the other code blocks in the Serialization tutorial can be copied and pasted, but there is one that includes the >>> shell prompt characters. This commit removes those characters, and also makes the output consistent with other code blocks by making it a comment.
This test was incorrectly checking that there were no validators set in
older versions of Django, even though it should have been checking for
the two validators that were set up on the model field level.
The originally regression test that this fixes was added in
7d79cf35b7
when fixing an issue with the `DecimalValidator`.
Previously, all validators set on a DecimalField in Django would be
stripped when converted to a Django REST framework field. This was
because any validator that was an instance of `DecimalValidator` would
be removed, and when `DecimalValidator` wasn't supported (so it was
`None`), all validators would be removed.
This fixes the issue by only removing the `DecimalValidator` instances
if the `DecimalValidator` is supported.
This adds tests for a regression where the `min_value` and `max_value`
arguments are not being set for a DRF `DecimalField` even though the
corresponding `MinValueValidator` and `MaxValueValidator` is being set
on the model fields.
Note that this only appears to be a regression for Django < 1.9, as
these regression tests pass on newer versions of Django.