Skip to main content

ifc_validate/structure/
mod.rs

1//! Structural conformance: references, slots, cardinality, uniqueness.
2//!
3//! ## Internals
4//!
5//! - `reference`: dangling and wrong-kind references
6//! - `required`: required/derived slot presence and record arity
7//! - `cardinality`: scalar-vs-aggregate shape
8//! - `bounds`: aggregate bounds, nesting and element uniqueness
9//! - `unique`: the release's `UNIQUE` clauses
10
11mod bounds;
12mod cardinality;
13mod reference;
14mod required;
15mod unique;
16
17pub use bounds::aggregate_bounds;
18pub use cardinality::aggregate_shape;
19pub(crate) use reference::expected_references;
20pub use reference::{dangling_references, wrong_kind_references};
21pub use required::required_attributes;
22pub use unique::unique_rules;
23
24use ifc_model::Model;
25use ifc_schema::Schema;
26
27use crate::report::Report;
28use crate::where_rule::Budget;
29
30/// Every structural check, in a fixed order.
31///
32/// Order is fixed so two runs over the same file produce identical reports;
33/// the report sorts findings anyway, but a stable production order keeps
34/// truncation deterministic when the budget is hit.
35pub fn check(model: &Model, schema: &Schema, budget: Budget, report: &mut Report) {
36    dangling_references(model, report);
37    wrong_kind_references(model, schema, report);
38    required_attributes(model, schema, report);
39    aggregate_shape(model, schema, report);
40    aggregate_bounds(model, schema, report);
41    unique_rules(model, schema, report);
42    if report.findings().len() >= budget.max_findings {
43        report.mark_truncated();
44    }
45}