Skip to content

Commit

Permalink
fix(i.e.): i.e. masks should only works for string values
Browse files Browse the repository at this point in the history
  • Loading branch information
the-darc committed May 15, 2015
1 parent 5856331 commit c0b4f06
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion releases/br-masks-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ var FINANCE = function(value, precision, decimalSep, groupSep) {

/*exported IE */
var IE = function(value, uf) {
if (!value || typeof value !== 'string') {
return value;
}

var ieMasks = {
'AC': [{mask: new StringMask('00.000.000/000-00')}],
'AL': [{mask: new StringMask('000000000')}],
Expand Down Expand Up @@ -330,7 +334,7 @@ var IE = function(value, uf) {
}

var mask = getMask(uf, value);
if(!value || !mask) {
if(!mask) {
return value;
}
var processed = mask.process(clearValue(value));
Expand Down Expand Up @@ -362,6 +366,7 @@ var PHONE = function(value) {
}

var formatedValue;
value = value + '';
if(value.length < 11){
formatedValue = phoneMask8D.apply(value);
}else{
Expand Down
2 changes: 1 addition & 1 deletion releases/br-masks-standalone.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion releases/br-masks.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ var FINANCE = function(value, precision, decimalSep, groupSep) {

/*exported IE */
var IE = function(value, uf) {
if (!value || typeof value !== 'string') {
return value;
}

var ieMasks = {
'AC': [{mask: new StringMask('00.000.000/000-00')}],
'AL': [{mask: new StringMask('000000000')}],
Expand Down Expand Up @@ -137,7 +141,7 @@ var IE = function(value, uf) {
}

var mask = getMask(uf, value);
if(!value || !mask) {
if(!mask) {
return value;
}
var processed = mask.process(clearValue(value));
Expand Down Expand Up @@ -169,6 +173,7 @@ var PHONE = function(value) {
}

var formatedValue;
value = value + '';
if(value.length < 11){
formatedValue = phoneMask8D.apply(value);
}else{
Expand Down
2 changes: 1 addition & 1 deletion releases/br-masks.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/ie.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/*exported IE */
var IE = function(value, uf) {
if (!value || typeof value !== 'string') {
return value;
}

var ieMasks = {
'AC': [{mask: new StringMask('00.000.000/000-00')}],
'AL': [{mask: new StringMask('000000000')}],
Expand Down Expand Up @@ -59,7 +63,7 @@ var IE = function(value, uf) {
}

var mask = getMask(uf, value);
if(!value || !mask) {
if(!mask) {
return value;
}
var processed = mask.process(clearValue(value));
Expand Down
4 changes: 4 additions & 0 deletions test/ie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ describe('I.E. ', function() {
should(BrM.ie('18100100000059', uf)).be.eql('18.1.001.0000005-9');
done();
});
it('should not mask numbers values', function(done) {
should(BrM.ie(032141840, uf)).be.eql(32141840);
done();
});
});
describe('- RS', function() {
var uf = 'RS';
Expand Down

0 comments on commit c0b4f06

Please sign in to comment.