Skip to content

Commit

Permalink
throw error if currency is not three letter code
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Jan 13, 2017
1 parent f1f1847 commit deaff2e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core_plugins/timelion/server/series_functions/yaxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ module.exports = new Chainable('yaxis', {
if (!tickFormatters[unitTokens[0]]) {
throw new Error (`${units} is not a supported unit type.`);
}
if (unitTokens[0] === 'currency') {
const threeLetterCode = /^[A-Za-z]{3}$/;
const currency = unitTokens[1];
if (currency && !threeLetterCode.test(currency)) {
throw new Error('Currency must be a three letter code');
}
}

myAxis.units = {
type: unitTokens[0],
prefix: unitTokens[1] || '',
Expand Down

0 comments on commit deaff2e

Please sign in to comment.