in scripts/validate.py [0:0]
def validate(schema_name, src_path):
schema = load_schema(schema_name)
resolver = NestedRefResolver(schema)
print(f"Validating {src_path} with {schema_name} schema...")
with open(src_path, "r") as f:
items = json.load(f)
if items is not None:
for item in items:
print(f"Valiating schema for {item['id']}")
try:
jsonschema.validate(
instance=item,
schema=schema,
resolver=resolver,
)
except ValidationError as err:
match = best_match([err])
print(f"Validation error: {match.message}")
sys.exit(1)
if schema_name == "message":
validate_message(item)
elif schema_name == "experiment":
validate_experiment(item)
elif schema_name == "message-group":
pass
elif schema_name == "action":
pass
print("PASS")