Skip to content

Instantly share code, notes, and snippets.

@brunomichetti
Created September 25, 2019 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunomichetti/90aa77036a25cacb4c7bbe7f11b31072 to your computer and use it in GitHub Desktop.
Save brunomichetti/90aa77036a25cacb4c7bbe7f11b31072 to your computer and use it in GitHub Desktop.
class PersonDetailSerializer(serializers.ModelSerializer):
def validate_age(self, age):
if age < 0:
raise serializers.ValidationError('Age must be a positive number.')
return age
class Meta:
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment