diff --git a/packages/input-amount/src/parsers.js b/packages/input-amount/src/parsers.js index 516b289fc..aeb76cb66 100644 --- a/packages/input-amount/src/parsers.js +++ b/packages/input-amount/src/parsers.js @@ -60,7 +60,8 @@ function getParseMode(value) { * @param {object} options Locale Options */ function parseWithLocale(value, options) { - const separator = getDecimalSeparator(options); + const locale = options && options.locale ? options.locale : null; + const separator = getDecimalSeparator(locale); const regexNumberAndLocaleSeparator = new RegExp(`[0-9${separator}-]`, 'g'); let numberAndLocaleSeparator = value.match(regexNumberAndLocaleSeparator).join(''); if (separator === ',') { diff --git a/packages/input-amount/test/parsers.test.js b/packages/input-amount/test/parsers.test.js index f266ce8aa..680293256 100644 --- a/packages/input-amount/test/parsers.test.js +++ b/packages/input-amount/test/parsers.test.js @@ -145,4 +145,17 @@ describe('parseAmount()', () => { it('returns undefined when value is empty string', () => { expect(parseAmount('')).to.equal(undefined); }); + + it('parseAmount with locale set and length is more than four', () => { + expect( + parseAmount('6,000', { + locale: 'gb-GB', + }), + ).to.equal(6000); + expect( + parseAmount('6.000', { + locale: 'es-ES', + }), + ).to.equal(6000); + }); });