Fix bug in validators documentation (#8779)

Function validators seem to have to return their value (which will become part of `validated_data`) as part of their signature.
This commit is contained in:
Floris Hoogenboom 2022-12-01 16:13:14 +00:00 committed by GitHub
parent 1ae812ea20
commit 614bd87b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -271,6 +271,7 @@ A validator may be any callable that raises a `serializers.ValidationError` on f
def even_number(value):
if value % 2 != 0:
raise serializers.ValidationError('This field must be an even number.')
return value
#### Field-level validation