mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 05:04:31 +03:00
Merge pull request #2115 from hgiasac/master
Fix typo "serailizers" to "serializers"
This commit is contained in:
commit
5cad60dc4f
|
@ -189,13 +189,13 @@ You can either return `non_field_errors` from the validate method by raising a s
|
|||
|
||||
def validate(self, attrs):
|
||||
# serializer.errors == {'non_field_errors': ['A non field error']}
|
||||
raise serailizers.ValidationError('A non field error')
|
||||
raise serializers.ValidationError('A non field error')
|
||||
|
||||
Alternatively if you want the errors to be against a specific field, use a dictionary of when instantiating the `ValidationError`, like so:
|
||||
|
||||
def validate(self, attrs):
|
||||
# serializer.errors == {'my_field': ['A field error']}
|
||||
raise serailizers.ValidationError({'my_field': 'A field error'})
|
||||
raise serializers.ValidationError({'my_field': 'A field error'})
|
||||
|
||||
This ensures you can still write validation that compares all the input fields, but that marks the error against a particular field.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user