MCPcopy
hub / github.com/encode/django-rest-framework / run_validation

Method run_validation

rest_framework/serializers.py:638–656  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

636 return dictionary.get(self.field_name, empty)
637
638 def run_validation(self, data=empty):
639 """
640 We override the default `run_validation`, because the validation
641 performed by validators and the `.validate()` method should
642 be coerced into an error dictionary with a 'non_fields_error' key.
643 """
644 (is_empty_value, data) = self.validate_empty_values(data)
645 if is_empty_value:
646 return data
647
648 value = self.to_internal_value(data)
649 try:
650 self.run_validators(value)
651 value = self.validate(value)
652 assert value is not None, '.validate() should return the validated data'
653 except (ValidationError, DjangoValidationError) as exc:
654 raise ValidationError(detail=as_serializer_error(exc))
655
656 return value
657
658 def run_child_validation(self, data):
659 """

Callers 1

is_validMethod · 0.95

Calls 6

to_internal_valueMethod · 0.95
validateMethod · 0.95
ValidationErrorClass · 0.90
as_serializer_errorFunction · 0.85
validate_empty_valuesMethod · 0.45
run_validatorsMethod · 0.45

Tested by

no test coverage detected