apollo_configuration/types/hashmap.rs
1//! Support for HashMap in configuration.
2
3use std::collections::HashMap;
4use std::hash::{BuildHasher, Hash};
5
6use crate::ErrorCollector;
7use crate::Validate;
8
9impl<K, V, S> Validate for HashMap<K, V, S>
10where
11 K: Eq + Hash + AsRef<str> + Validate,
12 V: Validate,
13 S: BuildHasher,
14{
15 fn validate(&self, mut errors: ErrorCollector<'_>) {
16 for (key, value) in self {
17 let path = key.as_ref();
18 // Validate the key at the map level (keys don't have their own path)
19 key.validate(errors.inner());
20 // Validate the value at its path
21 value.validate(errors.nest(path));
22 }
23 }
24}