diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba9b7b0..b264807 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+
+# [0.5.0](https://github.com/the-darc/br-masks/compare/0.4.1...0.5.0) (2016-11-09)
+
+
+### Features
+
+* **phone:** added support for 0800 phone numbers ([8fb2f46](https://github.com/the-darc/br-masks/commit/8fb2f46)), closes [#8](https://github.com/the-darc/br-masks/pull/8)
+* **cnpj-base:** added support for cnpj-base.js ([5cc07ff](https://github.com/the-darc/br-masks/commit/5cc07ff)), closes [#7](https://github.com/the-darc/br-masks/pull/7)
+
+
### 0.4.1 (2015-09-01)
diff --git a/bower.json b/bower.json
index 20fec6e..332a4b5 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "br-masks",
- "version": "0.4.1",
+ "version": "0.5.0",
"description": "A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others",
"homepage": "http://github.com/the-darc/br-masks",
"repository": {
@@ -33,6 +33,6 @@
"package.json"
],
"dependencies": {
- "string-mask": "^0.2.1"
+ "string-mask": "^0.3.0"
}
}
diff --git a/package.json b/package.json
index 2acd195..553e99b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "br-masks",
- "version": "0.4.1",
+ "version": "0.5.0",
"description": "A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others",
"id": "/br-masks",
"main": "releases/br-masks.js",
diff --git a/releases/br-masks-standalone.js b/releases/br-masks-standalone.js
index 2de0c72..298928c 100644
--- a/releases/br-masks-standalone.js
+++ b/releases/br-masks-standalone.js
@@ -69,9 +69,7 @@
}
StringMask.prototype.process = function proccess(value) {
- if (!value) {
- return {result: '', valid: false};
- }
+ if (!value) return '';
value = value + '';
var pattern2 = this.pattern;
var valid = true;
@@ -196,11 +194,12 @@
/**
* br-masks
* A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others
- * @version v0.4.1
+ * @version v0.5.0
* @link http://github.com/the-darc/br-masks
* @license MIT
*/
(function (root, factory) {
+ /* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['string-mask'], factory);
@@ -214,6 +213,7 @@
root.BrM = factory(root.StringMask);
}
}(this, function (StringMask) {
+ /* istanbul ignore if */
if (!StringMask) {
throw new Error('StringMask not found');
}
@@ -379,7 +379,8 @@ var NFEACCESSKEY = function(value) {
/*exported PHONE */
var PHONE = function(value) {
var phoneMask8D = new StringMask('(00) 0000-0000'),
- phoneMask9D = new StringMask('(00) 00000-0000');
+ phoneMask9D = new StringMask('(00) 00000-0000'),
+ phoneMask0800 = new StringMask('0000-000-0000');
if(!value) {
return value;
@@ -387,7 +388,9 @@ var PHONE = function(value) {
var formatedValue;
value = value + '';
- if(value.length < 11){
+ if (value.indexOf('0800') === 0) {
+ formatedValue = phoneMask0800.apply(value);
+ }else if(value.length < 11){
formatedValue = phoneMask8D.apply(value);
}else{
formatedValue = phoneMask9D.apply(value);
diff --git a/releases/br-masks-standalone.min.js b/releases/br-masks-standalone.min.js
index 796810d..39ce0e6 100644
--- a/releases/br-masks-standalone.min.js
+++ b/releases/br-masks-standalone.min.js
@@ -1 +1 @@
-!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?module.exports=n():e.StringMask=n()}(this,function(){function e(e,n){for(var t=0,r=n-1,s={escape:!0};r>=0&&s&&s.escape;)s=a[e.charAt(r)],t+=s&&s.escape?1:0,r--;return t>0&&t%2===1}function n(e,n){var t=e.replace(/[^0]/g,"").length,r=n.replace(/[^\d]/g,"").length;return r-t}function t(e,n,t,r){return r&&"function"==typeof r.transform&&(n=r.transform(n)),t.reverse?n+e:e+n}function r(e,n,t){var s=e.charAt(n),i=a[s];return""===s?!1:i&&!i.escape?!0:r(e,n+t,t)}function s(e,n,t){var r=e.split("");return r.splice(t>=0?t:0,0,n),r.join("")}function i(e,n){this.options=n||{},this.options={reverse:this.options.reverse||!1,usedefaults:this.options.usedefaults||this.options.reverse},this.pattern=e}var a={0:{pattern:/\d/,_default:"0"},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,optional:!0,recursive:!0},S:{pattern:/[a-zA-Z]/},U:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},L:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},$:{escape:!0}};return i.prototype.process=function(i){function o(e){if(!w&&r(p,k,m.inc))return!0;if(w||(w=v.length>0),w){var n=v.shift();if(v.push(n),e.reverse&&c>=0)return k++,p=s(p,n,k),!0;if(!e.reverse&&c=0}if(!i)return{result:"",valid:!1};i+="";for(var p=this.pattern,u=!0,f="",c=this.options.reverse?i.length-1:0,l=n(p,i),h=!1,v=[],w=!1,m={start:this.options.reverse?p.length-1:0,end:this.options.reverse?-1:p.length,inc:this.options.reverse?-1:1},k=m.start;o(this.options);k+=m.inc){var d=p.charAt(k),g=i.charAt(c),y=a[d];if(!w||g){if(this.options.reverse&&e(p,k)){f=t(f,d,this.options,y),k+=m.inc;continue}if(!this.options.reverse&&h){f=t(f,d,this.options,y),h=!1;continue}if(!this.options.reverse&&y&&y.escape){h=!0;continue}}if(!w&&y&&y.recursive)v.push(d);else{if(w&&!g){y&&y.recursive||(f=t(f,d,this.options,y));continue}if(v.length>0&&y&&!y.recursive){u=!1;continue}if(!w&&v.length>0&&!g)continue}if(y)if(y.optional){if(y.pattern.test(g)&&l)f=t(f,g,this.options,y),c+=m.inc,l--;else if(v.length>0&&g){u=!1;break}}else if(y.pattern.test(g))f=t(f,g,this.options,y),c+=m.inc;else{if(g||!y._default||!this.options.usedefaults){u=!1;break}f=t(f,y._default,this.options,y)}else f=t(f,d,this.options,y),!w&&v.length&&v.push(d)}return{result:f,valid:u}},i.prototype.apply=function(e){return this.process(e).result},i.prototype.validate=function(e){return this.process(e).valid},i.process=function(e,n,t){return new i(n,t).process(e)},i.apply=function(e,n,t){return new i(n,t).apply(e)},i.validate=function(e,n,t){return new i(n,t).validate(e)},i}),function(e,n){"function"==typeof define&&define.amd?define(["string-mask"],n):"object"==typeof exports?module.exports=n(require("string-mask")):e.BrM=n(e.StringMask)}(this,function(e){if(!e)throw new Error("StringMask not found");var n=function(n){var t=new e("00000-000");if(!n)return n;var r=t.process(n);return r.result},t=function(n){if(!n)return n;var t=new e("00.000.000"),r=t.apply(n);return r},r=function(n){if(!n)return n;var t=new e("00.000.000/0000-00"),r=t.apply(n);return r},s=function(e){return e&&e.length?e.length<=11?i(e):r(e):e},i=function(n){var t=new e("000.000.000-00");if(!n)return n;var r=t.apply(n);return r},a=function(n,t,r,s){t=!t&&0!==t||0>t?2:t,r=r||".",s=s||"";var i=t>0?r+new Array(t+1).join("0"):"",a="#"+s+"##0"+i;n=parseFloat(n),n||(n=0);var o=!1;0>n&&(n=-1*n,o=!0);var p=new e(a,{reverse:!0}),u=p.apply(n.toFixed(t).replace(/[^\d]+/g,""));return o?"("+u+")":u},o=function(n,t){function r(e){return e.replace(/[^0-9]/g,"")}function s(e,n){if(!e||!i[e])return void 0;var t=e.toUpperCase();if("SP"===t&&/^P/i.test(n))return i.SP[1].mask;for(var s=i[e],a=0;s[a].chars&&s[a].chars=0&&s&&s.escape;)s=a[e.charAt(r)],t+=s&&s.escape?1:0,r--;return t>0&&t%2===1}function n(e,n){var t=e.replace(/[^0]/g,"").length,r=n.replace(/[^\d]/g,"").length;return r-t}function t(e,n,t,r){return r&&"function"==typeof r.transform&&(n=r.transform(n)),t.reverse?n+e:e+n}function r(e,n,t){var s=e.charAt(n),i=a[s];return""!==s&&(!(!i||i.escape)||r(e,n+t,t))}function s(e,n,t){var r=e.split("");return r.splice(t>=0?t:0,0,n),r.join("")}function i(e,n){this.options=n||{},this.options={reverse:this.options.reverse||!1,usedefaults:this.options.usedefaults||this.options.reverse},this.pattern=e}var a={0:{pattern:/\d/,_default:"0"},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,optional:!0,recursive:!0},S:{pattern:/[a-zA-Z]/},U:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},L:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},$:{escape:!0}};return i.prototype.process=function(i){function o(e){if(!w&&r(p,k,m.inc))return!0;if(w||(w=v.length>0),w){var n=v.shift();if(v.push(n),e.reverse&&c>=0)return k++,p=s(p,n,k),!0;if(!e.reverse&&c=0}if(!i)return"";i+="";for(var p=this.pattern,u=!0,f="",c=this.options.reverse?i.length-1:0,l=n(p,i),h=!1,v=[],w=!1,m={start:this.options.reverse?p.length-1:0,end:this.options.reverse?-1:p.length,inc:this.options.reverse?-1:1},k=m.start;o(this.options);k+=m.inc){var d=p.charAt(k),g=i.charAt(c),y=a[d];if(!w||g){if(this.options.reverse&&e(p,k)){f=t(f,d,this.options,y),k+=m.inc;continue}if(!this.options.reverse&&h){f=t(f,d,this.options,y),h=!1;continue}if(!this.options.reverse&&y&&y.escape){h=!0;continue}}if(!w&&y&&y.recursive)v.push(d);else{if(w&&!g){y&&y.recursive||(f=t(f,d,this.options,y));continue}if(v.length>0&&y&&!y.recursive){u=!1;continue}if(!w&&v.length>0&&!g)continue}if(y)if(y.optional){if(y.pattern.test(g)&&l)f=t(f,g,this.options,y),c+=m.inc,l--;else if(v.length>0&&g){u=!1;break}}else if(y.pattern.test(g))f=t(f,g,this.options,y),c+=m.inc;else{if(g||!y._default||!this.options.usedefaults){u=!1;break}f=t(f,y._default,this.options,y)}else f=t(f,d,this.options,y),!w&&v.length&&v.push(d)}return{result:f,valid:u}},i.prototype.apply=function(e){return this.process(e).result},i.prototype.validate=function(e){return this.process(e).valid},i.process=function(e,n,t){return new i(n,t).process(e)},i.apply=function(e,n,t){return new i(n,t).apply(e)},i.validate=function(e,n,t){return new i(n,t).validate(e)},i}),function(e,n){"function"==typeof define&&define.amd?define(["string-mask"],n):"object"==typeof exports?module.exports=n(require("string-mask")):e.BrM=n(e.StringMask)}(this,function(e){if(!e)throw new Error("StringMask not found");var n=function(n){var t=new e("00000-000");if(!n)return n;var r=t.process(n);return r.result},t=function(n){if(!n)return n;var t=new e("00.000.000"),r=t.apply(n);return r},r=function(n){if(!n)return n;var t=new e("00.000.000/0000-00"),r=t.apply(n);return r},s=function(e){return e&&e.length?e.length<=11?i(e):r(e):e},i=function(n){var t=new e("000.000.000-00");if(!n)return n;var r=t.apply(n);return r},a=function(n,t,r,s){t=!t&&0!==t||t<0?2:t,r=r||".",s=s||"";var i=t>0?r+new Array(t+1).join("0"):"",a="#"+s+"##0"+i;n=parseFloat(n),n||(n=0);var o=!1;n<0&&(n*=-1,o=!0);var p=new e(a,{reverse:!0}),u=p.apply(n.toFixed(t).replace(/[^\d]+/g,""));return o?"("+u+")":u},o=function(n,t){function r(e){return e.replace(/[^0-9]/g,"")}function s(e,n){if(e&&i[e]){var t=e.toUpperCase();if("SP"===t&&/^P/i.test(n))return i.SP[1].mask;for(var s=i[e],a=0;s[a].chars&&s[a].charsr?2:r,a=a||".",t=t||"";var s=r>0?a+new Array(r+1).join("0"):"",i="#"+t+"##0"+s;e=parseFloat(e),e||(e=0);var u=!1;0>e&&(e=-1*e,u=!0);var w=new n(i,{reverse:!0}),f=w.apply(e.toFixed(r).replace(/[^\d]+/g,""));return u?"("+f+")":f},u=function(e,r){function a(n){return n.replace(/[^0-9]/g,"")}function t(n,e){if(!n||!s[n])return void 0;var r=n.toUpperCase();if("SP"===r&&/^P/i.test(e))return s.SP[1].mask;for(var t=s[n],i=0;t[i].chars&&t[i].chars0?a+new Array(r+1).join("0"):"",w="#"+t+"##0"+s;e=parseFloat(e),e||(e=0);var i=!1;e<0&&(e*=-1,i=!0);var u=new n(w,{reverse:!0}),f=u.apply(e.toFixed(r).replace(/[^\d]+/g,""));return i?"("+f+")":f},i=function(e,r){function a(n){return n.replace(/[^0-9]/g,"")}function t(n,e){if(n&&s[n]){var r=n.toUpperCase();if("SP"===r&&/^P/i.test(e))return s.SP[1].mask;for(var t=s[n],w=0;t[w].chars&&t[w].chars