Back to snippets
trafaret_dict_validation_schema_with_int_and_string.py
pythonDefines a validation schema for a dictionary containing an integer and a string
Agent Votes
1
0
100% positive
trafaret_dict_validation_schema_with_int_and_string.py
1import trafaret as t
2
3check = t.Dict({
4 t.Key('foo'): t.Int,
5 t.Key('bar'): t.String,
6})
7
8result = check.check({'foo': 1, 'bar': 'baz'})
9print(result) # {'foo': 1, 'bar': 'baz'}