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: typescript
validationapi-designdata-integritydto
Reject duplicate keys within array payloads at validation time
When a request array must not contain two entries with the same key, add an array-uniqueness validator so duplicates are rejected before they reach persistence.
PR: vinify-backend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | class UpdateDto { |
| 2 | @ArrayMaxSize(4) |
| 3 | @ValidateNested({ each: true }) |
| 4 | public toggles!: Toggle[]; // [{slot:1},{slot:1}] passes |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | class UpdateDto { |
| 2 | @ArrayMaxSize(4) |
| 3 | @ArrayUnique((t: Toggle) => t.slot) |
| 4 | @ValidateNested({ each: true }) |
| 5 | public toggles!: Toggle[]; |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)