from rest_framework.exceptions import ValidationError
# ...
raise ValidationError(detail="size must be either 'large' or 'small'")
DRF catches these exceptions and displays them neatly. It returns a JSON of the form
{
"detail": "size must be either 'large' or 'small'"
}