icydb_core/
validate.rs

1use crate::{
2    traits::Visitable,
3    visitor::{PathSegment, ValidateVisitor, VisitorAdapter, VisitorError, perform_visit},
4};
5
6///
7/// validate
8/// Validate a visitable tree, collecting issues by path.
9///
10/// Validation is non-failing at the traversal level. All validation
11/// issues are collected and returned to the caller, which may choose
12/// how to interpret them.
13///
14pub fn validate(node: &dyn Visitable) -> Result<(), VisitorError> {
15    let visitor = ValidateVisitor::new();
16    let mut adapter = VisitorAdapter::new(visitor);
17
18    perform_visit(&mut adapter, node, PathSegment::Empty);
19
20    adapter.result().map_err(VisitorError::from)
21}