Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1stack specificStack: NestJS
validationclass-validatordto
Use @ValidateNested with @Type for nested DTOs and arrays
Nested objects and arrays of DTOs are not validated unless annotated with @ValidateNested() and @Type(); without them class-validator silently skips them.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | export class BulkCreateDto { |
| 2 | notes: NoteDto[]; // not validated element-wise |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | export class BulkCreateDto { |
| 2 | @ValidateNested({ each: true }) |
| 3 | @Type(() => NoteDto) |
| 4 | notes: NoteDto[]; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)