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

Method run_validation

rest_framework/serializers.py:446–464  ·  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

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 = [

Callers 3

is_validMethod · 0.45
to_internal_valueMethod · 0.45
run_child_validationMethod · 0.45

Calls 6

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

Tested by

no test coverage detected