Commit a75d9b6d authored by Antoine's avatar Antoine
Browse files

Check the currency is known in the currency-related helpers.

parent 61fec0ab
......@@ -120,8 +120,16 @@ export const localeComparator = (function() {
export const currency = {
isKnown: c => typeof findCurrency(c) !== 'undefined',
symbolFor: c => findCurrency(c).symbol,
symbolFor: c => {
if (!currency.isKnown(c)) {
throw new Error(`Unknown currency: ${c}`);
}
return findCurrency(c).symbol;
},
makeFormat: c => {
if (!currency.isKnown(c)) {
throw new Error(`Unknown currency: ${c}`);
}
let { decimalDigits } = findCurrency(c);
return amount => {
let am = Math.abs(amount) < Math.pow(10, -decimalDigits - 2) ? 0 : amount;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment