Passing value: { amount: 0, code: '...' } into currency formatting results in an error, TypeError:valuemust be an object that has properties amount and code. The problem is that the amount property is checked for truthiness where the intent of the code was to check for presence: the check should be 'amount' in value instead of value.amount.
This is probably an easy fix, but a serious bug as 0 is a valid input and the result is a catastrophic error (app crash in my case). In my opinion a thrown error is an unacceptable outcome from a localization library; some reasonable fallback string should always come back from l(), or I have to wrap every localization site in a try-catch to preserve the integrity of my codebase...
Passing
value: { amount: 0, code: '...' }
into currency formatting results in an error,TypeError:
valuemust be an object that has properties amount and code
. The problem is that theamount
property is checked for truthiness where the intent of the code was to check for presence: the check should be'amount' in value
instead ofvalue.amount
.This is probably an easy fix, but a serious bug as
0
is a valid input and the result is a catastrophic error (app crash in my case). In my opinion a thrown error is an unacceptable outcome from a localization library; some reasonable fallback string should always come back froml()
, or I have to wrap every localization site in a try-catch to preserve the integrity of my codebase...