Skip to content

Commit bfce663

Browse files
authored
Update documentation regarding arguments of ValidationError (#8807)
The documentation used to state that the `detail` argument was mandatory, but in fact it currently is not.
1 parent 89d6ce7 commit bfce663

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

docs/api-guide/exceptions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,10 @@ By default this exception results in a response with the HTTP status code "429 T
217217

218218
## ValidationError
219219

220-
**Signature:** `ValidationError(detail, code=None)`
220+
**Signature:** `ValidationError(detail=None, code=None)`
221221

222222
The `ValidationError` exception is slightly different from the other `APIException` classes:
223223

224-
* The `detail` argument is mandatory, not optional.
225224
* The `detail` argument may be a list or dictionary of error details, and may also be a nested data structure. By using a dictionary, you can specify field-level errors while performing object-level validation in the `validate()` method of a serializer. For example. `raise serializers.ValidationError({'name': 'Please enter a valid name.'})`
226225
* By convention you should import the serializers module and use a fully qualified `ValidationError` style, in order to differentiate it from Django's built-in validation error. For example. `raise serializers.ValidationError('This field must be an integer value.')`
227226

0 commit comments

Comments
 (0)