-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple.py
More file actions
34 lines (27 loc) · 785 Bytes
/
Copy pathsimple.py
File metadata and controls
34 lines (27 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from simple_schema_validator import schema_validator
def main():
data = {
'status': 'OK',
'data': {
'id': 1,
'email': 'radorado@hacksoft.io',
'age': '29',
'username': 'radorado'
}
}
schema = {
'status': str,
'data': {
'id': int,
'email': str,
'age': int,
'token': str
}
}
validation = schema_validator(schema, data)
if not validation:
print(f'Keys in data, but not in schema: {validation.additional_keys}')
print(f'Keys in schema, but not in data: {validation.missing_keys}')
print(f'Keys with different type from schema {validation.type_errors}')
if __name__ == '__main__':
main()