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 ruleP2stack specificStack: NestJS
nestjsdtovalidation
Don't put validation decorators on response DTOs
Class-validator decorators only run through the validation pipe on incoming request payloads. Adding them to response/output DTOs does nothing but implies a guarantee that isn't enforced. Keep response DTOs as plain shape/serialization types.
PR: profico-org-corpus batch2 (all stacks/products)Created: Jul 26, 2026
Bad example
Old codets
| 1 | export class UserResponseDto { |
| 2 | @IsString() name: string; |
| 3 | @IsEmail() email: string; |
| 4 | } |
Explanation (EN)
These validators never execute on the way out, so they're dead decorators.
Objašnjenje (HR)
Good example
New codets
| 1 | export class UserResponseDto { |
| 2 | name: string; |
| 3 | email: string; |
| 4 | } |
Explanation (EN)
A response DTO just describes the output shape; validators belong on request DTOs.
Objašnjenje (HR)