icydb_core/validate.rs
1//! Module: validate
2//!
3//! Responsibility: module-local ownership and contracts for validate.
4//! Does not own: cross-module orchestration outside this module.
5//! Boundary: exposes this module API while keeping implementation details internal.
6
7use crate::{
8 traits::Visitable,
9 visitor::{
10 PathSegment, VisitorAdapter, VisitorError, perform_visit, validate::ValidateVisitor,
11 },
12};
13
14///
15/// validate
16/// Validate a visitable tree, collecting issues by path.
17///
18/// Validation is non-failing at the traversal level. All validation
19/// issues are collected and returned to the caller, which may choose
20/// how to interpret them.
21///
22pub fn validate(node: &dyn Visitable) -> Result<(), VisitorError> {
23 let visitor = ValidateVisitor::new();
24 let mut adapter = VisitorAdapter::new(visitor);
25
26 perform_visit(&mut adapter, node, PathSegment::Empty);
27
28 adapter.result().map_err(VisitorError::from)
29}