mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-16 19:41:06 +03:00
Add documentation link for single 'field-level validation' to the Validator docs page (#3772) (#4657)
This commit is contained in:
parent
7f437123bd
commit
0b9304014d
|
@ -272,6 +272,12 @@ A validator may be any callable that raises a `serializers.ValidationError` on f
|
|||
if value % 2 != 0:
|
||||
raise serializers.ValidationError('This field must be an even number.')
|
||||
|
||||
#### Field-level validation
|
||||
|
||||
You can specify custom field-level validation by adding `.validate_<field_name>` methods
|
||||
to your `Serializer` subclass. This is documented in the
|
||||
[Serializer docs](http://www.django-rest-framework.org/api-guide/serializers/#field-level-validation)
|
||||
|
||||
## Class-based
|
||||
|
||||
To write a class-based validator, use the `__call__` method. Class-based validators are useful as they allow you to parameterize and reuse behavior.
|
||||
|
|
Loading…
Reference in New Issue
Block a user