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