pub fn validate_attributes<'a, P, I>(
schemas: &IndexMap<String, IfcxSchema>,
nodes: I,
) -> ValidationReportExpand description
Checks the attributes of nodes, given as (path, attributes) pairs,
against schemas and collects every failure.
The pairs may come from raw file nodes or from flattened ones; see the module documentation for the rules.
use indexmap::IndexMap;
use openbim_ifcx::{validate_attributes, FailureKind, IfcxSchema};
use serde_json::json;
let schemas: IndexMap<String, IfcxSchema> = serde_json::from_value(json!({
"example::height": {"value": {"dataType": "Real"}}
})).unwrap();
let attributes: IndexMap<String, serde_json::Value> = serde_json::from_value(json!({
"example::height": "tall",
"example::colour": "red"
})).unwrap();
let report = validate_attributes(&schemas, [("wall", &attributes)]);
assert_eq!(report.failures.len(), 2);
assert_eq!(report.failures[1].kind, FailureKind::MissingSchema);