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).
fullstack ruleP1universalStack: any
formattingedge-casesnumberscorrectness
Handle the zero case explicitly in number formatters
A formatter that early-returns the raw value for falsy inputs will mis-handle 0; treat 0 as a real value and format it (e.g. '0,00').
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (!number) return number; // returns 0 unformatted |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (number == null) return number; |
| 2 | if (number === 0) return '0,00'; |
Explanation (EN)
Objašnjenje (HR)