Documentation
Container Validation
Container Validation
Validate your dependency graph during compile time to catch wiring errors early.
The container can validate service wiring before runtime to detect dependency graph issues early.
Programmatic usage
const result = await container.compile({
validate: true,
throwOnError: false
})
console.log(result.isValid)
console.log(result.errors)
console.log(result.warnings)
console.log(result.info)
By default, when validate: true and throwOnError is not false, compile throws ContainerValidationError if validation errors exist.
await container.compile({ validate: true })
Validation checks
Errors
- Missing dependency
- Circular dependency
- Unresolved parameters (
%param%)
Warnings
- Unused nullable references (
@?service) when target always exists - Deprecated service used by non-deprecated services
Info
- Tagged services without any tag consumer
- Keyed tag groups with multiple services and no
default: true
CLI usage
ndi container:validate [options] <path>
Options:
--format <format>:textorjson--strict: exit with code1when warnings are present
Examples:
ndi container:validate ./config/services.yaml
ndi container:validate --format=json ./config/services.yaml
ndi container:validate --strict ./config/services.yaml
Notes
- Without
validate: true, compile behaves as before. - With
throwOnError: false, compile returns the full validation report instead of throwing.
