Skip to content

Spec validation

Validation checks references, declarations, and dependency cycles. Errors are reported as ValueError; structured errors use SpecError, which includes a rule code and the location of the invalid declaration.

Spec validation is independent of implementation loading and binding implementation details. Use Binding inspector to compare declarations with Python implementation signatures.

After editing a document, call document.rebuild() before validating or compiling it so the checks use fresh declarations.

For validation examples, see Work with Spec documents.

Run spec validators in small, explicit groups.

validate_spec

validate_spec(spec: Spec) -> None

Run reference, declaration, graph, and warning checks in order.

Parameters:

Name Type Description Default
spec Spec

The structurally parsed spec document.

required

Raises:

Type Description
ValueError

A semantic invariant is violated.

Validation error types.

SpecError

Bases: ValueError

A semantic spec error with a stable code and resource path.

code instance-attribute

code = code

path instance-attribute

path = path