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).
frontend ruleP1universalStack: javascript
null-safetyvalidationcorrectness
Check the fields you care about, not just the wrapping object
When validating presence, test the specific nested values rather than the container object, which can be truthy while its fields are null.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const exists = Boolean(id && category && ticker && title && content); |
| 2 | // ticker is { id: null, symbol: null } -> still truthy |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const exists = Boolean(id && category && ticker?.id && title && content); |
Explanation (EN)
Objašnjenje (HR)