# Feature: Configuration Validation
### Scope
- **Purpose**: Validate configuration files against a JSON Schema derived from the target type before returning the deserialized value, catching structural errors before they cause runtime failures.
- **Responsibility**: Load a config file, derive a JSON Schema from the target type, validate the raw content against that schema, and return detailed per-field errors on failure.
- **In Scope**: Schema-validated configuration loading (requires `validation` feature, which also activates `serde`).
- **Out of Scope**: Runtime value validation (business logic), schema authoring tools, non-JSON-Schema validation formats, validation of non-config data.
### Design
Validation is integrated into the load step, not a separate pass. The operation loads the file, deserializes to an intermediate representation, then validates against the generated schema before converting into the target structure. All schema violations are collected and returned as a single error with per-field detail, not just the first error.
Schema generation derives from the target type definition at runtime via an annotation, requiring no separate schema file on disk.
The `validation` feature depends on `serde` — enabling validation automatically enables configuration loading, ensuring callers do not need to manage feature dependency manually.
### Sources
| [src/lib.rs](../../src/lib.rs) | Schema-validated config loading impl |
| [Cargo.toml](../../Cargo.toml) | `validation` feature flag (implies `serde`) and optional dependency declarations |
### Tests
| [tests/config_validation_tests.rs](../../tests/config_validation_tests.rs) | Schema-based configuration validation |
| [tests/validation_boundary_tests.rs](../../tests/validation_boundary_tests.rs) | Input validation and boundary condition handling |
### Tasks
| [task/completed/003_config_validation.md](../../task/completed/003_config_validation.md) | Initial schema validation implementation |
### APIs
| [api/001_workspace.md](../api/001_workspace.md) | `load_config_with_validation()` method signature |
### Features
| [feature/002_configuration_loading.md](../feature/002_configuration_loading.md) | Underlying config loading (serde feature) |