Skip to main content

icydb_core/
validate.rs

1//! Module: validate
2//!
3//! Responsibility: top-level validation entrypoint over visitable trees.
4//! Does not own: visitor diagnostics or per-type validation implementations.
5//! Boundary: convenient crate-level validation surface that delegates to visitor traversal.
6
7use crate::visitor::{
8    PathSegment, Visitable, VisitorAdapter, VisitorError, perform_visit, validate::ValidateVisitor,
9};
10
11///
12/// validate
13///
14/// Validate a visitable tree, collecting issues by path.
15///
16/// Validation is non-failing at the traversal level. All validation
17/// issues are collected and returned to the caller, which may choose
18/// how to interpret them.
19///
20pub fn validate(node: &dyn Visitable) -> Result<(), VisitorError> {
21    let visitor = ValidateVisitor::new();
22    let mut adapter = VisitorAdapter::new(visitor);
23
24    perform_visit(&mut adapter, node, PathSegment::Empty);
25
26    adapter.result().map_err(VisitorError::from)
27}