Skip to main content

ifc_validate/
type_check.rs

1//! Type conformance: entity types, scalars, enumerations, selects.
2//!
3//! ## Internals
4//!
5//! - `scalar`: EXPRESS primitives and the forms they accept
6//! - `enumeration`: enumeration membership
7//! - `select`: SELECT membership as a graph walk
8//! - `typed`: the form a value must take -- typed parameter or bare
9//! - `aggregate`: the element type an aggregate value is checked against
10//! - `defined`: one value against one declared type
11//! - `entity`: the per-entity sweep that reports findings
12
13mod aggregate;
14mod defined;
15mod entity;
16mod enumeration;
17mod scalar;
18mod select;
19mod typed;
20
21pub(crate) use aggregate::{aliased_aggregate, element_type};
22pub use defined::{check as check_value, Mismatch};
23pub use entity::{abstract_instances, attribute_types, unknown_entity_types};
24pub(crate) use scalar::describe_value;
25pub use scalar::Primitive;
26
27use ifc_model::Model;
28use ifc_schema::Schema;
29
30use crate::report::Report;
31use crate::where_rule::Budget;
32
33/// Every type check, in a fixed order.
34pub fn check(model: &Model, schema: &Schema, budget: Budget, report: &mut Report) {
35    unknown_entity_types(model, schema, report);
36    abstract_instances(model, schema, report);
37    attribute_types(model, schema, report);
38    if report.findings().len() >= budget.max_findings {
39        report.mark_truncated();
40    }
41}