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//! - `inverse`: the release's `INVERSE` cardinalities, on request
11//!   ([`crate::ValidateOptions::inverse_cardinality`])
12
13mod bounds;
14mod cardinality;
15mod inverse;
16mod reference;
17mod required;
18mod unique;
19
20pub use bounds::aggregate_bounds;
21pub use cardinality::aggregate_shape;
22pub use inverse::inverse_cardinality;
23pub(crate) use reference::expected_references;
24pub use reference::{dangling_references, wrong_kind_references};
25pub use required::required_attributes;
26pub use unique::unique_rules;
27
28use ifc_model::Model;
29use ifc_schema::Schema;
30
31use crate::report::Report;
32use crate::where_rule::Budget;
33
34/// Every structural check, in a fixed order.
35///
36/// Order is fixed so two runs over the same file produce identical reports;
37/// the report sorts findings anyway, but a stable production order keeps
38/// truncation deterministic when the budget is hit.
39pub fn check(model: &Model, schema: &Schema, budget: Budget, report: &mut Report) {
40    dangling_references(model, report);
41    wrong_kind_references(model, schema, report);
42    required_attributes(model, schema, report);
43    aggregate_shape(model, schema, report);
44    aggregate_bounds(model, schema, report);
45    unique_rules(model, schema, report);
46    if report.findings().len() >= budget.max_findings {
47        report.mark_truncated();
48    }
49}