Skip to main content

configbuilder_pattern_validator/
validator.rs

1use crate::ValidatorError;
2use std::path::Path;
3
4/// Validates a filesystem path before it is used as a config directory.
5///
6/// The reference implementation is [`crate::DefaultValidator`]. Import this trait
7/// only when writing generic code that accepts any validator.
8pub trait Validator {
9    /// Returns `Ok(())` when `target` is a valid config directory path, `Err` otherwise.
10    ///
11    /// A non-existent path is considered valid (it will be skipped at load time).
12    /// A path that exists but is not a directory returns [`ValidatorError::Io`].
13    fn validate_path(&self, target: &Path) -> Result<(), ValidatorError>;
14}