All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
17 lines
569 B
Python
17 lines
569 B
Python
from __future__ import annotations
|
|
from typing import Dict
|
|
from jsonschema import ValidationError
|
|
from .schema_loader import get_validator
|
|
|
|
NOTE_SCHEMA_NAME = "note.schema.json"
|
|
|
|
def validate_note_payload(payload: Dict) -> None:
|
|
validator = get_validator(NOTE_SCHEMA_NAME)
|
|
errors = sorted(validator.iter_errors(payload), key=lambda e: e.path)
|
|
if errors:
|
|
msgs = []
|
|
for e in errors:
|
|
loc = ".".join([str(x) for x in e.path]) or "<root>"
|
|
msgs.append(f"{loc}: {e.message}")
|
|
raise ValidationError(" | ".join(msgs))
|