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