Created
September 25, 2019 18:45
-
-
Save brunomichetti/90aa77036a25cacb4c7bbe7f11b31072 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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