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).
Back Up UI Copy That States a Limit With Matching Server-Side Validation
If the UI tells users "max size 5mb", the API must actually reject anything larger — the claim shouldn't be aspirational.
Bad example
| 1 | <Typography variant="b1Regular" fontSize="11px"> |
| 2 | (max size 5mb) |
| 3 | </Typography> |
| 4 |
|
| 5 | // no corresponding check anywhere in the upload API route or client handler |
Explanation (EN)
Displays a specific size limit as a promise to the user, but no code path — neither the client nor the API route — actually enforces it, so the message is misleading and files above 5mb may be silently accepted or fail with a confusing framework error.
Objašnjenje (HR)
Prikazuje korisniku specifično ograničenje veličine kao obećanje, ali nijedan dio koda — ni klijent ni API ruta — to zapravo ne provodi, pa je poruka zavaravajuća, a fileovi veći od 5mb mogu biti tiho prihvaćeni ili propasti uz zbunjujuću grešku frameworka.
Good example
| 1 | const MAX_UPLOAD_SIZE_BYTES = 5 * 1024 * 1024; |
| 2 |
|
| 3 | if (file.size > MAX_UPLOAD_SIZE_BYTES) { |
| 4 | showSnackbar({ message: 'File must be 5mb or smaller', severity: 'error' }); |
| 5 | return; |
| 6 | } |
Explanation (EN)
Adds an actual client-side (and matching server-side) check against the same limit shown in the UI copy, so the displayed constraint is a real, enforced rule instead of just text.
Objašnjenje (HR)
Dodaje stvarnu provjeru na klijentu (i odgovarajuću na serveru) prema istom ograničenju koje je prikazano u UI tekstu, tako da prikazano ograničenje postane stvarno provedeno pravilo, a ne samo tekst.