forked from ChelseaKR/ctdl-validate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.py
More file actions
25 lines (19 loc) · 773 Bytes
/
Copy pathvalidator.py
File metadata and controls
25 lines (19 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Orchestration: run every check over a parsed document."""
from __future__ import annotations
from typing import Any
from .checks import ALL_CHECKS
from .findings import Finding, finalize
from .graph import parse_document
from .schema import load_schema
def validate_document(data: Any) -> list[Finding]:
"""Validate a decoded CTDL JSON-LD document.
Accepts an object with @graph, a single entity object, or an array of
entities. Returns findings in a deterministic order. Raises
graph.DocumentError for shapes the tool does not read.
"""
schema = load_schema()
graph = parse_document(data, schema)
findings: list[Finding] = []
for check in ALL_CHECKS:
findings.extend(check(graph, schema))
return finalize(findings)