Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

br-validations

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

br-validations - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

CHANGELOG.md

2

bower.json
{
"name": "br-validations",
"version": "0.2.4",
"version": "0.3.0",
"description": "A library of validations applicable to several Brazilian data like I.E., CNPJ, CPF and others",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/the-darc/br-validations",

@@ -6,7 +6,10 @@ var gulp = require('gulp'),

config: path.join(__dirname, 'package.json')
});
}),
pkg = require('./package.json'),
fs = require('fs');
var path = {
var config = {
src: {
files: 'src/**/*.js'
files: 'src/**/*.js',
release: 'releases/br-validations.js'
},

@@ -48,7 +51,8 @@ test: {

' cpf: CPF,',
' cnpj: CNPJ',
' cnpj: CNPJ,',
' pis: PIS',
' };',
'}));'].join('\n');
gulp.src(path.src.files)
gulp.src(config.src.files)
.pipe(plugins.concat('br-validations.js'))

@@ -67,3 +71,3 @@ .pipe(plugins.header(header, {pkg: pkg}))

gulp.task('jshint', function(done) {
gulp.src(path.src.files)
gulp.src(config.src.files)
.pipe(plugins.jshint('.jshintrc'))

@@ -74,15 +78,17 @@ .pipe(plugins.jshint.reporter(jshintReporter));

gulp.task('runtestdot', function() {
gulp.src(path.test.files, {read: false})
.pipe(plugins.mocha({
reporter: 'dot'
}))
function mochaRunnerFactory(reporter) {
return plugins.mocha({
reporter: reporter || 'spec'
});
}
gulp.task('runtestdot', ['jshint', 'build'], function() {
gulp.src(config.test.files, {read: false})
.pipe(mochaRunnerFactory('dot'))
.on('error', console.warn.bind(console));
});
gulp.task('runtest', function() {
gulp.src(path.test.files, {read: false})
.pipe(plugins.mocha({
reporter: 'spec'
}))
gulp.task('runtest', ['jshint', 'build'], function() {
gulp.src(config.test.files, {read: false})
.pipe(mochaRunnerFactory())
.on('error', console.warn.bind(console));

@@ -92,3 +98,3 @@ });

gulp.task('default', ['jshint', 'build', 'runtestdot'], function() {
gulp.watch(path.src.files, ['jshint', 'build', 'runtestdot']);
gulp.watch(config.src.files, ['jshint', 'build', 'runtestdot']);
});

@@ -99,3 +105,44 @@

gulp.task('test-watch', ['jshint', 'build', 'runtest'], function() {
gulp.watch(path.src.files, ['jshint', 'build', 'runtest']);
gulp.watch(config.src.files, ['jshint', 'build', 'runtest']);
});
gulp.task('test-coverage', ['jshint'], function(done) {
gulp.src(config.src.release)
.pipe(plugins.istanbul())
.pipe(plugins.istanbul.hookRequire())
.on('finish', function() {
gulp.src(config.test.files, {
cwd: process.env.PWD,
read: false
})
.pipe(mochaRunnerFactory('spec'))
.pipe(plugins.istanbul.writeReports())
.on('end', function() {
if (process.env.TRAVIS) {
gulp.src('./coverage/**/lcov.info')
.pipe(plugins.coveralls())
.on('end', done);
} else {
done();
}
});
});
});
gulp.task('changelog', function(done) {
var changelog = require('conventional-changelog');
var options = {
repository: pkg.homepage,
version: pkg.version,
file: path.join(__dirname, 'CHANGELOG.md')
};
changelog(options, function(err, log) {
if (err) {
throw err;
}
fs.writeFile(options.file, log, done);
});
});
{
"name": "br-validations",
"version": "0.2.4",
"version": "0.3.0",
"description": "A library of validations applicable to several Brazilian data like I.E., CNPJ, CPF and others",

@@ -16,3 +16,4 @@ "id": "/br-validations",

"scripts": {
"test": "gulp test"
"test": "gulp test-coverage",
"postinstall": "gulp build"
},

@@ -24,3 +25,4 @@ "keywords": [

"cnpj",
"inscrição estadual"
"inscrição estadual",
"pis pasep"
],

@@ -34,6 +36,9 @@ "author": {

"devDependencies": {
"gulp": "^3.7.0",
"conventional-changelog": "0.0.17",
"gulp": "^3.9.0",
"gulp-concat": "^2.3.4",
"gulp-coveralls": "^0.1.4",
"gulp-footer": "^1.0.5",
"gulp-header": "^1.0.5",
"gulp-istanbul": "^0.10.0",
"gulp-jshint": "^1.6.1",

@@ -40,0 +45,0 @@ "gulp-load-plugins": "^0.5.3",

@@ -60,1 +60,17 @@ [![NPM version](https://badge.fury.io/js/br-validations.svg)](http://badge.fury.io/js/br-validations)

### PIS/PASEP ###
```javascript
var BrV = require('./br-validations');
var pis = '120.5825.883-7';
var isValid = BrV.pis.validate(pis);
```
## Contributing
We'd love for you to contribute to our source code! We just ask for you to:
- Follow the commit conventions of [conventional-changelog](https://github.com/ajoslin/conventional-changelog) described in
[conventional-conventions](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
- Write tests for the new feature or bug fix that you are solving
- Ensure all tests pass before send the pull-request (Use: `$ gulp test-coverage`)

@@ -638,7 +638,35 @@ /**

var PIS = {};
PIS.validate = function(pis) {
pis = pis.replace(/[^\d]+/g,'');
var r = /^(0{11}|1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11})$/;
if (!pis || pis.length !== 11 || r.test(pis)) {
return false;
}
var pisi = pis.substring(0,10);
var pisd = pis.substring(10);
function calculateDigit(pis){
var p = [3,2,9,8,7,6,5,4,3,2];
var s = 0;
for(var i = 0; i <= 9; i++){
s += parseInt(pis.charAt(i)) * p[i];
}
var r = 11 - (s%11);
return (r === 10 || r === 11) ? 0 : r;
}
return Number(pisd) === calculateDigit(pisi);
};
return {
ie: IE,
cpf: CPF,
cnpj: CNPJ
cnpj: CNPJ,
pis: PIS
};
}));

@@ -1,1 +0,1 @@

!function(s,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():s.BrV=t()}(this,function(){function s(s,t){var o=t.algorithmSteps,e=m.handleStr[o[0]](s),r=m.sum[o[1]](e,t.pesos),n=m.rest[o[2]](r),u=parseInt(e[t.dvpos]),a=m.expectedDV[o[3]](n,e);return u===a}function t(t,o){if(o.match&&!o.match.test(t))return!1;for(var e=0;e<o.dvs.length;e++)if(!s(t,o.dvs[e]))return!1;return!0}var o={};o.validate=function(s){var t=[6,5,4,3,2,9,8,7,6,5,4,3,2];s=s.replace(/[^\d]/g,"");var o=/^(0{14}|1{14}|2{14}|3{14}|4{14}|5{14}|6{14}|7{14}|8{14}|9{14})$/;if(!s||14!==s.length||o.test(s))return!1;s=s.split("");for(var e=0,r=0;12>e;e++)r+=s[e]*t[e+1];if(r=11-r%11,r=r>=10?0:r,parseInt(s[12])!==r)return!1;for(e=0,r=0;12>=e;e++)r+=s[e]*t[e];return r=11-r%11,r=r>=10?0:r,parseInt(s[13])!==r?!1:!0};var e={};e.validate=function(s){function t(t){for(var o=0,e=t-9,r=0;9>r;r++)o+=parseInt(s.charAt(r+e))*(r+1);return o%11%10===parseInt(s.charAt(t))}s=s.replace(/[^\d]+/g,"");var o=/^(0{11}|1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11})$/;return!s||11!==s.length||o.test(s)?!1:t(9)&&t(10)};var r=function(s){return this instanceof r?(this.rules=n[s]||[],this.rule,r.prototype._defineRule=function(s){this.rule=void 0;for(var t=0;t<this.rules.length&&void 0===this.rule;t++){var o=s.replace(/[^\d]/g,""),e=this.rules[t];o.length!==e.chars||e.match&&!e.match.test(s)||(this.rule=e)}return!!this.rule},r.prototype.validate=function(s){return s&&this._defineRule(s)?this.rule.validate(s):!1},void 0):new r(s)},n={},m={handleStr:{onlyNumbers:function(s){return s.replace(/[^\d]/g,"").split("")},mgSpec:function(s){var t=s.replace(/[^\d]/g,"");return t=t.substr(0,3)+"0"+t.substr(3,t.length),t.split("")}},sum:{normalSum:function(s,t){for(var o=s,e=0,r=0;r<t.length;r++)e+=parseInt(o[r])*t[r];return e},individualSum:function(s,t){for(var o=s,e=0,r=0;r<t.length;r++){var n=parseInt(o[r])*t[r];e+=n%10+parseInt(n/10)}return e},apSpec:function(s,t){var o=this.normalSum(s,t),e=s.join("");return e>="030000010"&&"030170009">=e?o+5:e>="030170010"&&"030190229">=e?o+9:o}},rest:{mod11:function(s){return s%11},mod10:function(s){return s%10},mod9:function(s){return s%9}},expectedDV:{minusRestOf11:function(s){return 2>s?0:11-s},minusRestOf11v2:function(s){return 2>s?11-s-10:11-s},minusRestOf10:function(s){return 1>s?0:10-s},mod10:function(s){return s%10},goSpec:function(s,t){var o=t.join("");return 1===s?o>="101031050"&&"101199979">=o?1:0:0===s?0:11-s},apSpec:function(s,t){var o=t.join("");return 0===s?o>="030170010"&&"030190229">=o?1:0:1===s?0:11-s},voidFn:function(s){return s}}};return n.PE=[{chars:9,dvs:[{dvpos:7,pesos:[8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}},{chars:14,pesos:[[1,2,3,4,5,9,8,7,6,5,4,3,2]],dvs:[{dvpos:13,pesos:[5,4,3,2,1,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11v2"]}],validate:function(s){return t(s,this)}}],n.RS=[{chars:10,dvs:[{dvpos:9,pesos:[2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.AC=[{chars:13,match:/^01/,dvs:[{dvpos:11,pesos:[4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:12,pesos:[5,4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MG=[{chars:13,dvs:[{dvpos:12,pesos:[1,2,1,2,1,2,1,2,1,2,1,2],algorithmSteps:["mgSpec","individualSum","mod10","minusRestOf10"]},{dvpos:12,pesos:[3,2,11,10,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.SP=[{chars:12,match:/^[0-9]/,dvs:[{dvpos:8,pesos:[1,3,4,5,6,7,8,10],algorithmSteps:["onlyNumbers","normalSum","mod11","mod10"]},{dvpos:11,pesos:[3,2,10,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","mod10"]}],validate:function(s){return t(s,this)}},{chars:12,match:/^P/i,dvs:[{dvpos:8,pesos:[1,3,4,5,6,7,8,10],algorithmSteps:["onlyNumbers","normalSum","mod11","mod10"]}],validate:function(s){return t(s,this)}}],n.DF=[{chars:13,dvs:[{dvpos:11,pesos:[4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:12,pesos:[5,4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.ES=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.BA=[{chars:8,match:/^[0123458]/,dvs:[{dvpos:7,pesos:[7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]},{dvpos:6,pesos:[8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]}],validate:function(s){return t(s,this)}},{chars:8,match:/^[679]/,dvs:[{dvpos:7,pesos:[7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:6,pesos:[8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}},{chars:9,match:/^[0-9][0123458]/,dvs:[{dvpos:8,pesos:[8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]},{dvpos:7,pesos:[9,8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]}],validate:function(s){return t(s,this)}},{chars:9,match:/^[0-9][679]/,dvs:[{dvpos:8,pesos:[8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:7,pesos:[9,8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.AM=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RN=[{chars:9,match:/^20/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}},{chars:10,match:/^20/,dvs:[{dvpos:8,pesos:[10,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RO=[{chars:14,dvs:[{dvpos:13,pesos:[6,5,4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PR=[{chars:10,dvs:[{dvpos:8,pesos:[3,2,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:9,pesos:[4,3,2,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.SC=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RJ=[{chars:8,dvs:[{dvpos:7,pesos:[2,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PA=[{chars:9,match:/^15/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.SE=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PB=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.CE=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PI=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MA=[{chars:9,match:/^12/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MT=[{chars:11,dvs:[{dvpos:10,pesos:[3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MS=[{chars:9,match:/^28/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.TO=[{chars:11,match:/^[0-9]{2}((0[123])|(99))/,dvs:[{dvpos:10,pesos:[9,8,0,0,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.AL=[{chars:9,match:/^24[03578]/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RR=[{chars:9,match:/^24/,dvs:[{dvpos:8,pesos:[1,2,3,4,5,6,7,8],algorithmSteps:["onlyNumbers","normalSum","mod9","voidFn"]}],validate:function(s){return t(s,this)}}],n.GO=[{chars:9,match:/^1[015]/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","goSpec"]}],validate:function(s){return t(s,this)}}],n.AP=[{chars:9,match:/^03/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","apSpec","mod11","apSpec"]}],validate:function(s){return t(s,this)}}],{ie:r,cpf:e,cnpj:o}});
!function(s,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():s.BrV=t()}(this,function(){function s(s,t){var r=t.algorithmSteps,e=m.handleStr[r[0]](s),o=m.sum[r[1]](e,t.pesos),n=m.rest[r[2]](o),u=parseInt(e[t.dvpos]),a=m.expectedDV[r[3]](n,e);return u===a}function t(t,r){if(r.match&&!r.match.test(t))return!1;for(var e=0;e<r.dvs.length;e++)if(!s(t,r.dvs[e]))return!1;return!0}var r={};r.validate=function(s){var t=[6,5,4,3,2,9,8,7,6,5,4,3,2];s=s.replace(/[^\d]/g,"");var r=/^(0{14}|1{14}|2{14}|3{14}|4{14}|5{14}|6{14}|7{14}|8{14}|9{14})$/;if(!s||14!==s.length||r.test(s))return!1;s=s.split("");for(var e=0,o=0;12>e;e++)o+=s[e]*t[e+1];if(o=11-o%11,o=o>=10?0:o,parseInt(s[12])!==o)return!1;for(e=0,o=0;12>=e;e++)o+=s[e]*t[e];return o=11-o%11,o=o>=10?0:o,parseInt(s[13])!==o?!1:!0};var e={};e.validate=function(s){function t(t){for(var r=0,e=t-9,o=0;9>o;o++)r+=parseInt(s.charAt(o+e))*(o+1);return r%11%10===parseInt(s.charAt(t))}s=s.replace(/[^\d]+/g,"");var r=/^(0{11}|1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11})$/;return!s||11!==s.length||r.test(s)?!1:t(9)&&t(10)};var o=function(s){return this instanceof o?(this.rules=n[s]||[],this.rule,o.prototype._defineRule=function(s){this.rule=void 0;for(var t=0;t<this.rules.length&&void 0===this.rule;t++){var r=s.replace(/[^\d]/g,""),e=this.rules[t];r.length!==e.chars||e.match&&!e.match.test(s)||(this.rule=e)}return!!this.rule},o.prototype.validate=function(s){return s&&this._defineRule(s)?this.rule.validate(s):!1},void 0):new o(s)},n={},m={handleStr:{onlyNumbers:function(s){return s.replace(/[^\d]/g,"").split("")},mgSpec:function(s){var t=s.replace(/[^\d]/g,"");return t=t.substr(0,3)+"0"+t.substr(3,t.length),t.split("")}},sum:{normalSum:function(s,t){for(var r=s,e=0,o=0;o<t.length;o++)e+=parseInt(r[o])*t[o];return e},individualSum:function(s,t){for(var r=s,e=0,o=0;o<t.length;o++){var n=parseInt(r[o])*t[o];e+=n%10+parseInt(n/10)}return e},apSpec:function(s,t){var r=this.normalSum(s,t),e=s.join("");return e>="030000010"&&"030170009">=e?r+5:e>="030170010"&&"030190229">=e?r+9:r}},rest:{mod11:function(s){return s%11},mod10:function(s){return s%10},mod9:function(s){return s%9}},expectedDV:{minusRestOf11:function(s){return 2>s?0:11-s},minusRestOf11v2:function(s){return 2>s?11-s-10:11-s},minusRestOf10:function(s){return 1>s?0:10-s},mod10:function(s){return s%10},goSpec:function(s,t){var r=t.join("");return 1===s?r>="101031050"&&"101199979">=r?1:0:0===s?0:11-s},apSpec:function(s,t){var r=t.join("");return 0===s?r>="030170010"&&"030190229">=r?1:0:1===s?0:11-s},voidFn:function(s){return s}}};n.PE=[{chars:9,dvs:[{dvpos:7,pesos:[8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}},{chars:14,pesos:[[1,2,3,4,5,9,8,7,6,5,4,3,2]],dvs:[{dvpos:13,pesos:[5,4,3,2,1,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11v2"]}],validate:function(s){return t(s,this)}}],n.RS=[{chars:10,dvs:[{dvpos:9,pesos:[2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.AC=[{chars:13,match:/^01/,dvs:[{dvpos:11,pesos:[4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:12,pesos:[5,4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MG=[{chars:13,dvs:[{dvpos:12,pesos:[1,2,1,2,1,2,1,2,1,2,1,2],algorithmSteps:["mgSpec","individualSum","mod10","minusRestOf10"]},{dvpos:12,pesos:[3,2,11,10,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.SP=[{chars:12,match:/^[0-9]/,dvs:[{dvpos:8,pesos:[1,3,4,5,6,7,8,10],algorithmSteps:["onlyNumbers","normalSum","mod11","mod10"]},{dvpos:11,pesos:[3,2,10,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","mod10"]}],validate:function(s){return t(s,this)}},{chars:12,match:/^P/i,dvs:[{dvpos:8,pesos:[1,3,4,5,6,7,8,10],algorithmSteps:["onlyNumbers","normalSum","mod11","mod10"]}],validate:function(s){return t(s,this)}}],n.DF=[{chars:13,dvs:[{dvpos:11,pesos:[4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:12,pesos:[5,4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.ES=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.BA=[{chars:8,match:/^[0123458]/,dvs:[{dvpos:7,pesos:[7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]},{dvpos:6,pesos:[8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]}],validate:function(s){return t(s,this)}},{chars:8,match:/^[679]/,dvs:[{dvpos:7,pesos:[7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:6,pesos:[8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}},{chars:9,match:/^[0-9][0123458]/,dvs:[{dvpos:8,pesos:[8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]},{dvpos:7,pesos:[9,8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod10","minusRestOf10"]}],validate:function(s){return t(s,this)}},{chars:9,match:/^[0-9][679]/,dvs:[{dvpos:8,pesos:[8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:7,pesos:[9,8,7,6,5,4,3,0,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.AM=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RN=[{chars:9,match:/^20/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}},{chars:10,match:/^20/,dvs:[{dvpos:8,pesos:[10,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RO=[{chars:14,dvs:[{dvpos:13,pesos:[6,5,4,3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PR=[{chars:10,dvs:[{dvpos:8,pesos:[3,2,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]},{dvpos:9,pesos:[4,3,2,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.SC=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RJ=[{chars:8,dvs:[{dvpos:7,pesos:[2,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PA=[{chars:9,match:/^15/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.SE=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PB=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.CE=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.PI=[{chars:9,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MA=[{chars:9,match:/^12/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MT=[{chars:11,dvs:[{dvpos:10,pesos:[3,2,9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.MS=[{chars:9,match:/^28/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.TO=[{chars:11,match:/^[0-9]{2}((0[123])|(99))/,dvs:[{dvpos:10,pesos:[9,8,0,0,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.AL=[{chars:9,match:/^24[03578]/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","minusRestOf11"]}],validate:function(s){return t(s,this)}}],n.RR=[{chars:9,match:/^24/,dvs:[{dvpos:8,pesos:[1,2,3,4,5,6,7,8],algorithmSteps:["onlyNumbers","normalSum","mod9","voidFn"]}],validate:function(s){return t(s,this)}}],n.GO=[{chars:9,match:/^1[015]/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","normalSum","mod11","goSpec"]}],validate:function(s){return t(s,this)}}],n.AP=[{chars:9,match:/^03/,dvs:[{dvpos:8,pesos:[9,8,7,6,5,4,3,2],algorithmSteps:["onlyNumbers","apSpec","mod11","apSpec"]}],validate:function(s){return t(s,this)}}];var u={};return u.validate=function(s){function t(s){for(var t=[3,2,9,8,7,6,5,4,3,2],r=0,e=0;9>=e;e++)r+=parseInt(s.charAt(e))*t[e];var o=11-r%11;return 10===o||11===o?0:o}s=s.replace(/[^\d]+/g,"");var r=/^(0{11}|1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11})$/;if(!s||11!==s.length||r.test(s))return!1;var e=s.substring(0,10),o=s.substring(10);return Number(o)===t(e)},{ie:o,cpf:e,cnpj:r,pis:u}});
var should = require('should'),
BrV = require('../releases/br-validations.min');
BrV = require('../releases/br-validations');

@@ -4,0 +4,0 @@ describe('br-validations', function(){

var should = require('should'),
BrV = require('../releases/br-validations.min');
BrV = require('../releases/br-validations');

@@ -4,0 +4,0 @@ describe('br-validations', function(){

var should = require('should'),
BrV = require('../releases/br-validations.min');
BrV = require('../releases/br-validations');

@@ -4,0 +4,0 @@ describe('br-validations', function(){

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc