Schema¶
JSON Schema validation helpers for PrairieLearn elements.
The rendered messages intentionally mirror the wording produced by the
@prairielearn/tree-sitter-htmlmustache linter so that an instructor sees the
same text whether a problem is caught at lint time (in the editor) or at render
time (in Python). Keep the two in sync when changing either.
validate_element ¶
validate_element(
element: HtmlElement,
schema_path: Path,
*,
parent_tag: str | None = None,
) -> None
Validate an element's attributes against a PrairieLearn element schema.
parent_tag, when provided, is woven into the message the same way the
linter does for nested elements (e.g. <pl-answer> inside <pl-multiple-choice>).
Raises:
| Type | Description |
|---|---|
ValueError
|
If the element's attributes do not satisfy the schema. |