We override the default `run_validation`, because the validation performed by validators and the `.validate()` method should be coerced into an error dictionary with a 'non_fields_error' key.
(self, data=empty)
| 444 | return dictionary.get(self.field_name, empty) |
| 445 | |
| 446 | def run_validation(self, data=empty): |
| 447 | """ |
| 448 | We override the default `run_validation`, because the validation |
| 449 | performed by validators and the `.validate()` method should |
| 450 | be coerced into an error dictionary with a 'non_fields_error' key. |
| 451 | """ |
| 452 | (is_empty_value, data) = self.validate_empty_values(data) |
| 453 | if is_empty_value: |
| 454 | return data |
| 455 | |
| 456 | value = self.to_internal_value(data) |
| 457 | try: |
| 458 | self.run_validators(value) |
| 459 | value = self.validate(value) |
| 460 | assert value is not None, '.validate() should return the validated data' |
| 461 | except (ValidationError, DjangoValidationError) as exc: |
| 462 | raise ValidationError(detail=as_serializer_error(exc)) |
| 463 | |
| 464 | return value |
| 465 | |
| 466 | def _read_only_defaults(self): |
| 467 | fields = [ |
no test coverage detected