use kaptan_config::{Config, ConfigViolation}; #[derive(Config)] struct Child { #[config(id = 1, key = "child.value", unit = "count", range(min = 0, max = 2))] value: u32, } #[derive(Config)] #[config(post = Self::validate_complete)] struct Root { child: Child, } impl Root { fn validate_complete(&self) -> Result<(), ConfigViolation> { self.child.validate() } } fn main() { let root = Root { child: Child { value: 1 }, }; assert_eq!(Root::FIELD_COUNT, 1); assert_eq!(root.child.field_value(kaptan_config::FieldId::new(1)), Some(kaptan_config::ConfigValue::U32(1))); }