mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Docstrings
This commit is contained in:
parent
117a24cfc6
commit
2a3d07d9d3
|
@ -182,7 +182,7 @@ By default this exception results in a response with the HTTP status code "429 T
|
||||||
|
|
||||||
## ValidationError
|
## ValidationError
|
||||||
|
|
||||||
**Signature:** `ValidationError(detail)`
|
**Signature:** `ValidationError(detail, code=None)`
|
||||||
|
|
||||||
The `ValidationError` exception is slightly different from the other `APIException` classes:
|
The `ValidationError` exception is slightly different from the other `APIException` classes:
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,19 @@ class ValidationError(APIException):
|
||||||
return six.text_type(self.detail)
|
return six.text_type(self.detail)
|
||||||
|
|
||||||
def get_codes(self):
|
def get_codes(self):
|
||||||
|
"""
|
||||||
|
Return only the code part of the error details.
|
||||||
|
|
||||||
|
Eg. {"name": ["required"]}
|
||||||
|
"""
|
||||||
return _get_codes(self.detail)
|
return _get_codes(self.detail)
|
||||||
|
|
||||||
def get_full_details(self):
|
def get_full_details(self):
|
||||||
|
"""
|
||||||
|
Return both the message & code parts of the error details.
|
||||||
|
|
||||||
|
Eg. {"name": [{"message": "This field is required.", "code": "required"}]}
|
||||||
|
"""
|
||||||
return _get_full_details(self.detail)
|
return _get_full_details(self.detail)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user