Skip to content

Commit

Permalink
Merge 2b06aea into 595240a
Browse files Browse the repository at this point in the history
  • Loading branch information
hbdbim committed Jan 25, 2019
2 parents 595240a + 2b06aea commit 14daabe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ releases
*.swp
.idea
*.iml
/.vs
14 changes: 8 additions & 6 deletions src/br/boleto-bancario/boleto-bancario.js
Expand Up @@ -4,21 +4,23 @@ var StringMask = require('string-mask');
var maskFactory = require('../../helpers/mask-factory');

var boletoBancarioMask = new StringMask('00000.00000 00000.000000 00000.000000 0 00000000000000');
var tributoBancarioMask = new StringMask('00000000000-0 00000000000-0 00000000000-0 00000000000-0');

module.exports = maskFactory({
clearValue: function(rawValue) {
return rawValue.replace(/[^0-9]/g, '').slice(0, 47);
clearValue: function (rawValue) {
return rawValue.replace(/[^0-9]/g, '').slice(0, 48);
},
format: function(cleanValue) {
format: function (cleanValue) {
if (cleanValue.length === 0) {
return cleanValue;
}

if (cleanValue[0] === '8')
return tributoBancarioMask.apply(cleanValue).replace(/[^0-9]$/, '');
return boletoBancarioMask.apply(cleanValue).replace(/[^0-9]$/, '');
},
validations: {
brBoletoBancario: function(value) {
return value.length === 47;
brBoletoBancario: function (value) {
return [47, 48].indexOf(value.length) >= 0;
}
}
});

0 comments on commit 14daabe

Please sign in to comment.