In the NestJS documentation there is a section about partial registration. It says it allows to load feature-specific configuration files in different directories:
import databaseConfig from './config/database.config';
@Module({
imports: [ConfigModule.forFeature(databaseConfig)],
})
export class DatabaseModule {}
However, it seems that it is not possible to provide a feature-specific validation schema, as Config
is the only argument that you can give to the forFeature
method.
Am I correct to assume that I would need to provide this database config validation schema in the ConfigModule.forRoot
method?
This seems to defeat the purpose of a feature specific configuration file as the validation would need to be defined higher up?
Are there other ways to achieve partial registration with validation?