mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 20:10:10 +03:00
validates ModelField value against field.null state
This commit is contained in:
parent
5e0b96b035
commit
7d9f1b7878
|
@ -429,6 +429,11 @@ class ModelField(WritableField):
|
||||||
"type": self.model_field.get_internal_type()
|
"type": self.model_field.get_internal_type()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def validate(self, value):
|
||||||
|
super(ModelField, self).validate(value)
|
||||||
|
if value is None and not self.model_field.null:
|
||||||
|
raise ValidationError(self.error_messages['invalid'])
|
||||||
|
|
||||||
|
|
||||||
##### Typed Fields #####
|
##### Typed Fields #####
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user