Created
March 21, 2020 19:23
-
-
Save ceb10n/ac18ce66b3be9f3c4a1fb116070c6a83 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
try: | |
user_schema = UserSchema().load({ | |
'id': 12345, | |
'name': 'Rafael de Oliveira Marques', | |
'nick': 'cebion', | |
'email': 'rafaelomarques@gmail.com' | |
}) | |
except ValidationError as validation_err: | |
pprint.pprint(validation_err.messages) | |
pprint.pprint(validation_err.valid_data) | |
# Bad data | |
# {'id': ['Not a valid UUID.']} | |
# Good data | |
# {'email': 'rafaelomarques@gmail.com', | |
# 'name': 'Rafael de Oliveira Marques', | |
# 'nick': 'cebion'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment