igf_api_py_client/BaseEntity.py

23 lines
589 B
Python
Raw Normal View History

2024-12-22 14:10:39 +03:00
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