Skip to main content

icydb_core/
validate.rs

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