Skip to content

Instantly share code, notes, and snippets.

@xsleonard
Created May 3, 2013 11:24
Show Gist options
  • Save xsleonard/5508581 to your computer and use it in GitHub Desktop.
Save xsleonard/5508581 to your computer and use it in GitHub Desktop.
voluptuous validation failure
from voluptuous import Schema
data = {
'InactiveMails': 26,
'Bounces': [
{
'Name': 'All',
'Count': 30
},
{
'Type': 'HardBounce',
'Name': 'Hard bounce',
'Count': 26
},
{
'Type': 'Transient',
'Name': 'Message delayed',
'Count': 3
},
{
'Type': 'Blocked',
'Name': 'ISP block',
'Count': 1
}
]
}
schema = Schema(data, required=True)
# Fails with:
# voluptuous.voluptuous.MultipleInvalid: not a valid value for dictionary value @ data['Bounces'][1]['Count']
schema(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment