apollo-configuration 0.4.0

A typed, friendly configuration system for Apollo products.
Documentation
//! Support for HashMap in configuration.

use std::collections::HashMap;
use std::hash::{BuildHasher, Hash};

use crate::ErrorCollector;
use crate::Validate;

impl<K, V, S> Validate for HashMap<K, V, S>
where
    K: Eq + Hash + AsRef<str> + Validate,
    V: Validate,
    S: BuildHasher,
{
    fn validate(&self, mut errors: ErrorCollector<'_>) {
        for (key, value) in self {
            let path = key.as_ref();
            // Validate the key at the map level (keys don't have their own path)
            key.validate(errors.inner());
            // Validate the value at its path
            value.validate(errors.nest(path));
        }
    }
}