diff --git a/reporter.js b/reporter.js index 6b4642d..bdae535 100644 --- a/reporter.js +++ b/reporter.js @@ -21,9 +21,15 @@ function parse(data) { throw new Error('Bad Title'); } - if (typeof data.amount !== 'number') { + if (typeof data.amount !== 'number' || typeof data.amount !== 'string') { throw new Error('Bad amount'); } + + if (typeof data.amount === 'string') { + const value = Number(data.amount.replaceAll(/[^\d]/g, '')); + data.amount = Number.isNaN(value) ? 0 : value; + } + return data; }