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 ruleP1universalStack: node
dtovalidationnullableupdate
Allow null on update DTO fields that should be clearable
If a field must be settable back to empty, it has to accept null in the update DTO or the database value can never be cleared.
PR: vinify-backend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | @IsOptional() |
| 2 | @IsInt() |
| 3 | public regionId?: number; // cannot send null to clear |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | @IsOptional() |
| 2 | @IsInt() |
| 3 | @ValidateIf((_, v) => v !== null) |
| 4 | public regionId?: number | null; |
Explanation (EN)
Objašnjenje (HR)