Skip to main content

validate_spec

Function validate_spec 

Source
pub fn validate_spec(spec_dir: &Path) -> Result<ValidationResult, Error>
Expand description

Validate a spec against its layer schemas.

Runs two layers of checks over every file reachable from the index(es):

  1. Structural (hand-rolled) — well-formedness, cross-file ID uniqueness (XSD xs:ID only enforces within a single document; clayers specs are multi-file so this fills that gap), and cross-layer reference resolution (rel:relation from/to, art:artifact/@repo).
  2. Schema-driven (XSD 1.1) — required attributes, pattern facets (e.g. hash format), enumeration restrictions (e.g. coverage values), content-model conformance, and strict xs:any namespace="##other" wildcard resolution. Delegated to crate::xsd_validation::validate_against_schemas, which uses the uppsala crate under the hood. Runs only when a schema directory is reachable from spec_dir.

Both layers contribute to the same flat error list; the caller can print them directly or test is_valid() to gate a build.

§Errors

Returns an error if spec files cannot be discovered or read, or if the schema-driven validator cannot be constructed.