MCPcopy Index your code
hub / github.com/encode/django-rest-framework / run_validators

Method run_validators

rest_framework/fields.py:542–564  ·  view source on GitHub ↗

Test the given value against all the validators on the field, and either raise a `ValidationError` or simply return.

(self, value)

Source from the content-addressed store, hash-verified

540 return value
541
542 def run_validators(self, value):
543 """
544 Test the given value against all the validators on the field,
545 and either raise a `ValidationError` or simply return.
546 """
547 errors = []
548 for validator in self.validators:
549 try:
550 if getattr(validator, 'requires_context', False):
551 validator(value, self)
552 else:
553 validator(value)
554 except ValidationError as exc:
555 # If the validation error contains a mapping of fields to
556 # errors then simply raise it immediately rather than
557 # attempting to accumulate a list of errors.
558 if isinstance(exc.detail, dict):
559 raise
560 errors.extend(exc.detail)
561 except DjangoValidationError as exc:
562 errors.extend(get_error_detail(exc))
563 if errors:
564 raise ValidationError(errors)
565
566 def to_internal_value(self, data):
567 """

Callers 1

run_validationMethod · 0.95

Calls 2

ValidationErrorClass · 0.90
get_error_detailFunction · 0.85

Tested by

no test coverage detected