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 ruleP2universalStack: Node/HTTP
input-validationapi-designsimplicity
Validate input before calling, and avoid needlessly wrapping a single arg in an object
Return the error response as soon as a required input is missing instead of delegating that check, and pass a lone value directly rather than wrapping it in a one-key object.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const result = await purgeSingleImageCache({ url: body.url }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const { url } = req.body as PurgeSingleImageRequest; |
| 2 | if (!url) { |
| 3 | return res.status(400).json({ error: 'URL parameter is required' }); |
| 4 | } |
| 5 | const result = await purgeSingleImageCache(url); |
Explanation (EN)
Objašnjenje (HR)