Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Keep frontend write contracts limited to the current UI scope
Do not expose backend fields in frontend create or update payloads unless the current UI actually reads, edits, or intentionally forwards them.
Bad example
| 1 | export interface UpdatePortfolioDividendPayload { |
| 2 | dividendPerShare: number; |
| 3 | source?: string; |
| 4 | notes?: string; |
| 5 | } |
| 6 |
|
| 7 | if (source != null && typeof source !== 'string') { |
| 8 | return badRequest('source must be a string'); |
| 9 | } |
| 10 |
|
| 11 | if (notes != null && typeof notes !== 'string') { |
| 12 | return badRequest('notes must be a string'); |
| 13 | } |
Explanation (EN)
The frontend widens its write surface to include DB or tracking fields that the product is not using. That adds maintenance cost and review noise without user value.
Objašnjenje (HR)
Frontend siri svoj write surface na DB ili tracking polja koja proizvod ne koristi. To dodaje trosak odrzavanja i review noise bez korisnicke vrijednosti.
Good example
| 1 | export interface UpdatePortfolioDividendPayload { |
| 2 | dividendPerShare: number; |
| 3 | dividendCurrency: string; |
| 4 | sharesHeld: number; |
| 5 | exchangeRate: number; |
| 6 | portfolioCurrency: string; |
| 7 | amount: number; |
| 8 | exDate: string; |
| 9 | payDate: string; |
| 10 | } |
Explanation (EN)
The write contract contains only fields the current UI genuinely owns. Response models may still include backend-only fields, but write payloads stay narrow.
Objašnjenje (HR)
Write contract sadrzi samo polja koja trenutni UI stvarno posjeduje. Response modeli i dalje mogu ukljucivati backend-only polja, ali write payloadi ostaju uski.
Notes (EN)
Separate response completeness from write scope. The backend may return more fields than the frontend should be allowed to send back.
Bilješke (HR)
Odvoji potpunost responsea od write scopea. Backend moze vratiti vise polja nego sto frontend treba smjeti poslati natrag.
Exceptions / Tradeoffs (EN)
Include hidden or passthrough fields only when there is an explicit product or backend requirement and that requirement is documented in code.
Iznimke / Tradeoffi (HR)
Ukljuci skrivena ili passthrough polja samo kada postoji eksplicitan product ili backend zahtjev i taj zahtjev je dokumentiran u kodu.