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 ruleP1universalStack: node
apivalidationerror-handlinguploads
Reject unsupported multi-item requests with a clear error status
When an endpoint supports only a single item (e.g. one image), validate and reject extra items with a custom error status and message instead of silently processing only the first.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const file = files[0]; // silently ignores files[1..] |
| 2 | await upload(file); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (files.length > 1) { |
| 2 | return res.status(409).json({ message: 'Only one image is allowed' }); |
| 3 | } |
| 4 | await upload(files[0]); |
Explanation (EN)
Objašnjenje (HR)