Comparing version 2.2.2 to 2.2.3
@@ -75,3 +75,4 @@ "use strict"; | ||
prefix: 'R$ ', | ||
suffix: '' | ||
suffix: '', | ||
allowNegative: true | ||
}) | ||
@@ -78,0 +79,0 @@ }, |
@@ -287,3 +287,3 @@ "use strict"; | ||
} | ||
var regex = /^(R\$|R\$ )?((\d{1,3})(?:.[0-9]{3}){0,1}|(\d{1})(?:.[0-9]{3}){0,2}|(\d{1,7}))(\,\d{1,2})?$/g; | ||
var regex = /^(R\$|R\$ )?(()-(\d{1,3})(?:.[0-9]{3}){0,1}|(\d{1})(?:.[0-9]{3}){0,2}|(\d{1,7}))(\,\d{1,2})?$/g; | ||
return regex.test(currency); | ||
@@ -290,0 +290,0 @@ } |
@@ -97,2 +97,5 @@ "use strict"; | ||
var currencyNumberMany = 5103.9423234; | ||
var currencyTextNegative = '-5.103,94'; | ||
var currencyNumberNegative = -125.95; | ||
var currencyNegative = '-R$ 5.103,94'; | ||
chai_1.expect(index_1.maskBr.currency(currencyNoDecimals)).to.be.equal('R$ 5.103,00'); | ||
@@ -105,2 +108,5 @@ chai_1.expect(index_1.maskBr.currency(currencyTextNoDecimals)).to.be.equal('R$ 5.103,00'); | ||
chai_1.expect(index_1.maskBr.currency(currencyNumberMany)).to.be.equal('R$ 5.103,94'); | ||
chai_1.expect(index_1.maskBr.currency(currencyTextNegative)).to.be.equal('-R$ 5.103,94'); | ||
chai_1.expect(index_1.maskBr.currency(currencyNumberNegative)).to.be.equal('-R$ 125,95'); | ||
chai_1.expect(index_1.maskBr.currency(currencyNegative)).to.be.equal('-R$ 5.103,94'); | ||
// testGeneric('currency'); | ||
@@ -107,0 +113,0 @@ // expect(maskBr.currency('123')).to.exist; |
@@ -150,6 +150,10 @@ "use strict"; | ||
chai_1.expect(index_1.validateBr.currency('1.234,56')).to.be.true; | ||
chai_1.expect(index_1.validateBr.currency('-1.234,56')).to.be.true; | ||
chai_1.expect(index_1.validateBr.currency('R$ -1.234,56')).to.be.true; | ||
}); | ||
it('Error when not valid', function () { | ||
chai_1.expect(index_1.validateBr.currency('$1234')).to.be.false; | ||
chai_1.expect(index_1.validateBr.currency('$-1234')).to.be.false; | ||
chai_1.expect(index_1.validateBr.currency('1,234.00')).to.be.false; | ||
chai_1.expect(index_1.validateBr.currency('-1,234.00')).to.be.false; | ||
}); | ||
@@ -156,0 +160,0 @@ }); |
{ | ||
"name": "js-brasil", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Javascript Utils para Brasil (cpf, cnpj...)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -75,3 +75,4 @@ import { isArray, processCaretTraps } from './utils'; | ||
prefix: 'R$ ', | ||
suffix: '' | ||
suffix: '', | ||
allowNegative : true | ||
}) | ||
@@ -78,0 +79,0 @@ }, |
@@ -330,3 +330,3 @@ import { getAllDigits, fillString, getAllWords } from "./utils"; | ||
} | ||
const regex = /^(R\$|R\$ )?((\d{1,3})(?:.[0-9]{3}){0,1}|(\d{1})(?:.[0-9]{3}){0,2}|(\d{1,7}))(\,\d{1,2})?$/g; | ||
const regex = /^(R\$|R\$ )?(()-(\d{1,3})(?:.[0-9]{3}){0,1}|(\d{1})(?:.[0-9]{3}){0,2}|(\d{1,7}))(\,\d{1,2})?$/g; | ||
return regex.test(currency); | ||
@@ -333,0 +333,0 @@ } |
@@ -114,2 +114,5 @@ import { maskBr, fakerBr, validateBr } from '../index'; | ||
const currencyNumberMany = 5103.9423234; | ||
const currencyTextNegative = '-5.103,94'; | ||
const currencyNumberNegative = -125.95; | ||
const currencyNegative = '-R$ 5.103,94'; | ||
@@ -124,2 +127,5 @@ expect(maskBr.currency(currencyNoDecimals)).to.be.equal('R$ 5.103,00'); | ||
expect(maskBr.currency(currencyNumberMany)).to.be.equal('R$ 5.103,94'); | ||
expect(maskBr.currency(currencyTextNegative)).to.be.equal('-R$ 5.103,94'); | ||
expect(maskBr.currency(currencyNumberNegative)).to.be.equal('-R$ 125,95'); | ||
expect(maskBr.currency(currencyNegative)).to.be.equal('-R$ 5.103,94'); | ||
// testGeneric('currency'); | ||
@@ -126,0 +132,0 @@ // expect(maskBr.currency('123')).to.exist; |
@@ -167,6 +167,10 @@ import { validateBr } from '../index'; | ||
expect(validateBr.currency('1.234,56')).to.be.true; | ||
expect(validateBr.currency('-1.234,56')).to.be.true; | ||
expect(validateBr.currency('R$ -1.234,56')).to.be.true; | ||
}); | ||
it('Error when not valid', () => { | ||
expect(validateBr.currency('$1234')).to.be.false; | ||
expect(validateBr.currency('$-1234')).to.be.false; | ||
expect(validateBr.currency('1,234.00')).to.be.false; | ||
expect(validateBr.currency('-1,234.00')).to.be.false; | ||
}); | ||
@@ -173,0 +177,0 @@ }) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2160080
37221