What this thread does
Do first: give each service one owning NestJS module, export only its public service or token, and install a global ValidationPipe({ transform: true, whitelist: true, forbidNonWhitelisted: true }).
Short answer
As of November 2026, this card targets NestJS 12.4.0 (November 6 release).
Choose / don't choose
- Feature module: choose one owner for a capability and its repository; don't redeclare its public service in every consumer.
- Public token: choose to decouple consumers from the implementation using
useExisting; don't export the repository merely to share one business operation (alias providers). - Explicit conversion: choose field-specific
@Type/@Transformor parsing pipes when query input semantics matter. Don't enable implicit conversion globally just to make one numeric filter pass; class-transformer warns against doing so alongside class-validator (conversion contract).
Not for: Express browser CORS failures; see express-cors-middleware-app-use-cors-origin-list-credentials-preflight.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
ValidationPipe.whitelist | true filters properties lacking validation decorators | Current class-based Nest validation | validation |
forbidNonWhitelisted | true together with whitelist rejects extra properties rather than stripping silently | Current class-based Nest validation | validation |
transform | true returns DTO instances and supports primitive route/query conversion | Current Nest validation | validation |
enableImplicitConversion | Keep false unless deliberately accepting reflected type coercion; implicit type conversion is disabled by default | Current transformer contract | transformer |
imports, providers, exports | Consumer imports owning module; owner provides service/repository and exports only service | Current module contract | modules |
useExisting | Create aliases for an existing provider | Current provider contract | custom providers |
ParseIntPipe, ParseBoolPipe | Use at parameter boundary for explicit integer/boolean input contracts | Current built-in pipes | pipes |
Order of operations
1. Inspect npm ls @nestjs/core @nestjs/common class-validator class-transformer (npm listing). Move one controller and service into a feature module while preserving route decorators. Keep its repository private. Import the module into root/consumers (module guide). 2. For example, an Orders module has providers: [OrdersService, OrdersRepository] and exports: [OrdersService]; consumers use imports: [OrdersModule]. These are application class names. For an interface boundary, export one shared token constant and inject that exact token; useExisting: OrdersService avoids another service instance. 3. Install validator/transformer dependencies if absent. Use runtime-imported DTO classes, not interfaces. Do not use type-only imports for DTOs. Decorate every allowed field; @Allow() is available when whitelisting should retain a field without another validator (validator whitelist). 4. Transform incoming strings deliberately, then validate their domain constraints before the controller calls the service. For a query integer DTO field use @Type(() => Number) plus integer/range validators; conversion itself does not enforce positivity or valid pagination bounds. For boolean strings, prefer ParseBoolPipe on a scalar parameter or an explicit accepted-value transform (transformer, pipes). 5. Confirm a valid DTO reaches the service; invalid shape, invalid integer and extra-property requests should fail before the service call. Internal callers that bypass HTTP pipes still need service/domain invariants. The migration guide describes StandardSchemaValidationPipe as a schema-first alternative to ValidationPipe plus class-validator; this card retains class-based DTOs. 6. Inspect connection initialization after the split. kelp-vishal's April 30, 2026 Nx discussion reports duplicate DB connections after an earlier Nest upgrade; it concerns dynamic-module identity, not a current-release regression.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
Nest can't resolve dependencies of | Provider absent, exported token’s module not imported, duplicate registration, or erased injection type | Review the named module and constructor index; register in owner, export public token, import owner in consumer; use runtime imports | common errors |
imports entry is undefined | A circular dependency between modules | Move shared tokens to an independent file and extract shared capability; use documented forward references only for unavoidable cycles | common errors |
"false" becomes true | Boolean conversion via Boolean(value) | Keep implicit conversion disabled and parse the accepted boolean spellings explicitly | QuanticPotatoes, March 4, 2021 report |
Diagnostic: Nest can't resolve dependencies of
A provider belongs in providers, not imports. An interface has no runtime token; use a concrete class or shared explicit token. Duplicating a provider in a feature module and a root module instantiates it twice.
Missing
- DTO fields, accepted boolean spellings and domain ranges depend on the API contract. Validation is not authorization or an internal service boundary guarantee.
Checked
2026-11-12; NestJS 12.4.0 (release); linked Nest/npm references, validator/transformer docs, QuanticPotatoes report and kelp-vishal discussion read. No Nest commands executed.
Started from a post by @NestJS, packaged by the editor. Original post