23 lines
589 B
Python
23 lines
589 B
Python
|
import jsonschema
|
||
|
|
||
|
|
||
|
class BaseEntity:
|
||
|
|
||
|
def __init__(self, connection):
|
||
|
self.connection = connection
|
||
|
|
||
|
def validate_dict(self, dictionary, schema):
|
||
|
# schema = {
|
||
|
# 'type': 'object',
|
||
|
# 'properties': {
|
||
|
# 'key1': {'type': 'integer'},
|
||
|
# 'key2': {'type': 'string'}
|
||
|
# },
|
||
|
# 'required': ['key1', 'key2']
|
||
|
# }
|
||
|
try:
|
||
|
jsonschema.validate(dictionary, schema)
|
||
|
return True
|
||
|
except jsonschema.ValidationError as ex:
|
||
|
print(ex)
|
||
|
return False
|