27 lines
549 B
Python
27 lines
549 B
Python
import json
|
|
import jsonschema
|
|
|
|
with open("config.schema.json") as file:
|
|
schema = json.load(file)
|
|
|
|
|
|
def validate(config: dict | list):
|
|
"""Validate the specified config
|
|
|
|
Args:
|
|
config: The raw configuration
|
|
|
|
Returns:
|
|
True if the config is valid, False otherwise
|
|
"""
|
|
try:
|
|
jsonschema.validate(config, schema)
|
|
except jsonschema.SchemaError:
|
|
print("Schema invalid")
|
|
return False
|
|
except jsonschema.ValidationError:
|
|
print("Config invalid")
|
|
return False
|
|
|
|
return True
|