configbuilder-pattern-validator 0.1.0

configbuilder-pattern: validator domain, trait contract + tech-agnostic reference implementation.
Documentation
//! Canonical usage of the `Validator` trait against a minimal local implementor.
//!
//! `configbuilder-svc-validator-spi`'s `FsValidatorOps` is the real,
//! filesystem-backed implementor; this example shows the trait shape without
//! touching a real filesystem.

use configbuilder_pattern_validator::{Validator, ValidatorError};
use std::path::Path;

struct AlwaysValid;

impl Validator for AlwaysValid {
    fn validate_path(&self, _target: &Path) -> Result<(), ValidatorError> {
        Ok(())
    }
}

fn check(v: &dyn Validator, path: &str) {
    match v.validate_path(Path::new(path)) {
        Ok(()) => println!("{path}: ok"),
        Err(e) => eprintln!("{path}: {e}"),
    }
}

fn main() {
    check(&AlwaysValid, "/etc/my-app");
}