Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Convert string inputs to numbers before numeric comparison
Validate numeric text and convert before numeric operations; coercion alone is not validation.
Bad example
| 1 | if (a.temperature > b.temperature) {} // both are strings |
Explanation (EN)
Numeric text compared as strings sorts lexicographically.
Objašnjenje (HR)
Good example
| 1 | const left = parseFiniteTemperature(a.temperature); |
| 2 | const right = parseFiniteTemperature(b.temperature); |
| 3 | if (left > right) { /* numeric comparison */ } |
Explanation (EN)
The existing domain parser rejects empty, malformed and unsupported temperature representations.
Objašnjenje (HR)
Notes (EN)
Parse accepted numeric text at the boundary, validate finite/range/precision requirements, then perform numeric comparisons.
Exceptions / Tradeoffs (EN)
Number("") and Number(null) produce zero. Locale separators, units and large integers need an explicit parser or another representation; string ordering can be intentional for textual identifiers.