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

Class ValidationError

rest_framework/exceptions.py:143–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141# raise serializers.ValidationError('Value was invalid')
142
143class ValidationError(APIException):
144 status_code = status.HTTP_400_BAD_REQUEST
145 default_detail = _('Invalid input.')
146 default_code = 'invalid'
147
148 def __init__(self, detail=None, code=None):
149 if detail is None:
150 detail = self.default_detail
151 if code is None:
152 code = self.default_code
153
154 # For validation failures, we may collect many errors together,
155 # so the details should always be coerced to a list if not already.
156 if isinstance(detail, tuple):
157 detail = list(detail)
158 elif not isinstance(detail, dict) and not isinstance(detail, list):
159 detail = [detail]
160
161 self.detail = _get_error_details(detail, code)
162
163
164class ParseError(APIException):

Callers 15

validate_nestedMethod · 0.90
validation_errorFunction · 0.90
is_validMethod · 0.90
run_validationMethod · 0.90
to_internal_valueMethod · 0.90
run_validationMethod · 0.90
to_internal_valueMethod · 0.90
is_validMethod · 0.90
run_validatorsMethod · 0.90
failMethod · 0.90
run_child_validationMethod · 0.90

Calls 1

_Function · 0.85

Tested by 3

validate_nestedMethod · 0.72
validation_errorFunction · 0.72