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

js-brasil

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-brasil - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

19

dist/index.js

@@ -16,3 +16,3 @@ "use strict";

var validate_1 = require("./src/validate");
var inscricaoestadual_1 = require("./src/inscricaoestadual");
exports.validateBr = validate_1.validateBr;
var faker = require("./src/faker");

@@ -23,19 +23,2 @@ var mask = require("./src/mask");

var estados_1 = require("./src/estados");
exports.validateBr = {
cep: validate_1.valida_cep,
cnpj: validate_1.validate_cnpj,
cpf: validate_1.validate_cpf,
currency: validate_1.validate_currency,
number: validate_1.validate_number,
inscricaoestadual: inscricaoestadual_1.validar,
percentage: validate_1.validate_percentage,
rg: validate_1.validate_rg,
placa: placa_1.validate_placa,
renavam: validate_1.validate_renavam,
telefone: validate_1.validate_telefone,
celular: validate_1.validate_celular,
time: validate_1.validate_time,
titulo: validate_1.validate_titulo,
processo: validate_1.validate_processo
};
exports.utilsBr = __assign({}, utils, { MASKS: mask_1.MASKS,

@@ -42,0 +25,0 @@ PLACAS_RANGE: placa_1.PLACAS_RANGE,

1

dist/src/faker.js

@@ -123,2 +123,3 @@ "use strict";

percentage: makeGeneric(mask_1.MASKS['percentage']),
pispasep: makeGeneric(mask_1.MASKS['pispasep']),
placa: function () {

@@ -125,0 +126,0 @@ var placa;

@@ -15,23 +15,2 @@ "use strict";

},
rg: {
text: 'AA-00.000.000',
textMask: [/[A-Za-z]/, /[A-Za-z]/, '-', /\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/]
},
telefone: {
text: '(00) 0000-0000',
textMask: ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
textMaskFunction: function mask(userInput) {
var numbers = userInput.match(/\d/g);
var numberLength = 0;
if (numbers) {
numberLength = numbers.join('').length;
}
if (!userInput || numberLength > 10) {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
else {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
}
},
celular: {

@@ -41,2 +20,6 @@ text: '(00) 00000-0000',

},
creditcard: {
text: '0000 0000 0000 0000 00/00 000',
textMask: [/\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, '0', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, '/', /\d/, /\d/, ' ', /\d/, /\d/, /\d/]
},
cep: {

@@ -46,7 +29,2 @@ text: '00.000-000',

},
inscricaoestadual: inscricaoestadual_1.IEMASKS,
time: {
text: '00:00',
textMask: [/\d/, /\d/, ':', /\d/, /\d/]
},
currency: {

@@ -64,2 +42,3 @@ text: '0.000,00',

},
inscricaoestadual: inscricaoestadual_1.IEMASKS,
number: {

@@ -77,2 +56,6 @@ text: '0.000,00',

},
pispasep: {
text: '000.00000.00-0',
textMask: [/\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, '-', /\d/]
},
percentage: {

@@ -94,6 +77,2 @@ text: '00,00%',

},
titulo: {
text: '0000.0000.0000',
textMask: [/\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/]
},
processo: {

@@ -103,2 +82,6 @@ text: '0000000-00.0000.AAA.0000',

},
rg: {
text: 'AA-00.000.000',
textMask: [/[A-Za-z]/, /[A-Za-z]/, '-', /\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/]
},
renavam: {

@@ -121,6 +104,27 @@ text: '0000000000-00',

},
creditcard: {
text: '0000 0000 0000 0000 00/00 000',
textMask: [/\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, '0', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, '/', /\d/, /\d/, ' ', /\d/, /\d/, /\d/]
telefone: {
text: '(00) 0000-0000',
textMask: ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
textMaskFunction: function mask(userInput) {
var numbers = userInput.match(/\d/g);
var numberLength = 0;
if (numbers) {
numberLength = numbers.join('').length;
}
if (!userInput || numberLength > 10) {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
else {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
}
},
titulo: {
text: '0000.0000.0000',
textMask: [/\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/]
},
time: {
text: '00:00',
textMask: [/\d/, /\d/, ':', /\d/, /\d/]
},
utils: {

@@ -201,2 +205,3 @@ numberToString: function (n) {

},
pispasep: makeGeneric('pispasep'),
placa: makeGeneric('placa'),

@@ -203,0 +208,0 @@ renavam: makeGeneric('renavam'),

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var inscricaoestadual_1 = require("./inscricaoestadual");
var placa_1 = require("./placa");
// http://www.geradorcnpj.com/javascript-validar-cnpj.htm

@@ -203,2 +205,7 @@ /*

exports.validate_currency = validate_currency;
function validate_pispasep(number) {
var regex = /^\d{3}\.\d{5}\.\d{2}\-\d{1}$/;
return regex.test(number);
}
exports.validate_pispasep = validate_pispasep;
function validate_number(number) {

@@ -329,2 +336,20 @@ var regex = /^\d+(?:\.\d{0,2})$/;

exports.create_renavam = create_renavam;
exports.validateBr = {
cep: valida_cep,
celular: validate_celular,
cnpj: validate_cnpj,
cpf: validate_cpf,
currency: validate_currency,
number: validate_number,
inscricaoestadual: inscricaoestadual_1.validar,
percentage: validate_percentage,
pispasep: validate_pispasep,
placa: placa_1.validate_placa,
processo: validate_processo,
renavam: validate_renavam,
rg: validate_rg,
telefone: validate_telefone,
time: validate_time,
titulo: validate_titulo
};
//# sourceMappingURL=validate.js.map

@@ -19,2 +19,6 @@ "use strict";

});
it('Faker celular', function () {
var celular = index_1.fakerBr.celular();
chai_1.expect(index_1.validateBr.celular(celular)).to.be.true;
});
it('Faker CEP', function () {

@@ -32,2 +36,8 @@ var cep = index_1.fakerBr.cep();

});
it('Faker Currency', function () {
// const currency = fakerBr.currency();
// expect(validateBr.currency(currency)).to.be.true;
var currencyNumber = index_1.fakerBr.currencyNumber();
chai_1.expect(index_1.validateBr.currency(currencyNumber)).to.be.true;
});
it('Faker RG', function () {

@@ -37,2 +47,10 @@ var rg = index_1.fakerBr.rg();

});
it('Faker RENAVAM', function () {
var renavam = index_1.fakerBr.renavam();
chai_1.expect(index_1.validateBr.renavam(renavam)).to.be.true;
});
it('Faker PIS/PASEP', function () {
var pispasep = index_1.fakerBr.pispasep();
chai_1.expect(index_1.validateBr.pispasep(pispasep)).to.be.true;
});
it('Faker PLACA', function () {

@@ -46,6 +64,2 @@ var placa = index_1.fakerBr.placa();

});
it('Faker celular', function () {
var celular = index_1.fakerBr.celular();
chai_1.expect(index_1.validateBr.celular(celular)).to.be.true;
});
// it('Faker Time', () => {

@@ -55,2 +69,6 @@ // const time = fakerBr.time();

// });
// const inscricaoestadual = fakerBr.inscricaoestadual();
// expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// const percentage = fakerBr.percentage();
// expect(validateBr.percentage(percentage)).to.be.true;
it('Faker Titulo', function () {

@@ -60,15 +78,3 @@ var titulo = index_1.fakerBr.titulo();

});
it('Faker Moeda', function () {
var currency = index_1.fakerBr.currency();
var currencyNumber = index_1.fakerBr.currencyNumber();
// expect(validateBr.currency(currency)).to.be.true;
chai_1.expect(index_1.validateBr.currency(currencyNumber)).to.be.true;
});
it('Faker Others', function () {
// const inscricaoestadual = fakerBr.inscricaoestadual();
// expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// const percentage = fakerBr.percentage();
// expect(validateBr.percentage(percentage)).to.be.true;
});
});
//# sourceMappingURL=faker.js.map

@@ -13,26 +13,8 @@ "use strict";

it('To generate any data', function () {
chai_1.expect(index_1.maskBr.cep('123')).to.exist;
chai_1.expect(index_1.maskBr.cnpj('123')).to.exist;
chai_1.expect(index_1.maskBr.cpf('123')).to.exist;
// expect(maskBr.currency('123')).to.exist;
// expect(maskBr.currency(123)).to.exist;
chai_1.expect(index_1.maskBr.inscricaoestadual('mg', '123')).to.exist;
chai_1.expect(index_1.maskBr.percentage('123')).to.exist;
chai_1.expect(index_1.maskBr.rg('123')).to.exist;
chai_1.expect(index_1.maskBr.placa('123')).to.exist;
chai_1.expect(index_1.maskBr.telefone('123')).to.exist;
chai_1.expect(index_1.maskBr.time('123')).to.exist;
chai_1.expect(index_1.maskBr.titulo('123')).to.exist;
chai_1.expect(index_1.maskBr.processo('123')).to.exist;
});
it('Generic Testing with Faker , Mask and Validate', function () {
testGeneric('cnpj');
// testGeneric('currency');
// testGeneric('inscricaoestadual');
// testGeneric('percentage');
testGeneric('rg');
// testGeneric('telefone');
// testGeneric('time');
testGeneric('titulo');
// testGeneric('processo');
});

@@ -43,2 +25,3 @@ it('CEP', function () {

testGeneric('cep');
chai_1.expect(index_1.maskBr.cep('123')).to.exist;
});

@@ -48,2 +31,4 @@ it('CNPJ', function () {

chai_1.expect(index_1.maskBr.cnpj(cnpj)).to.be.equal('83.529.443/1831-82');
chai_1.expect(index_1.maskBr.cnpj('123')).to.exist;
testGeneric('cnpj');
});

@@ -54,25 +39,5 @@ it('CPF', function () {

testGeneric('cpf');
chai_1.expect(index_1.maskBr.cpf('123')).to.exist;
});
it('RG MG', function () {
var rg = 'mg11164324';
chai_1.expect(index_1.maskBr.rg(rg)).to.be.equal('mg-11.164.324');
});
it('PLACA', function () {
var placa = 'ABC1234';
chai_1.expect(index_1.maskBr.placa(placa)).to.be.equal('ABC-1234');
testGeneric('placa');
});
it('Telefone', function () {
var telefone = '3135003500';
chai_1.expect(index_1.maskBr.telefone(telefone)).to.be.equal('(31) 3500-3500');
});
it('Telefone 9 Digito', function () {
var telefone = '31988886565';
chai_1.expect(index_1.maskBr.telefone(telefone)).to.be.equal('(31) 98888-6565');
});
it('Processos', function () {
var processo = '000001001520081000000';
// expect(maskBr.processo(processo)).to.be.equal('00000100-15.2008.100.0000');
});
it('Moeda', function () {
it('Currency', function () {
var currency = 'R$ 5.103,94';

@@ -92,23 +57,61 @@ var currencyText = '5.103,94';

chai_1.expect(index_1.maskBr.currency(currencyNumberMany)).to.be.equal('R$ 5.103,94');
// testGeneric('currency');
// expect(maskBr.currency('123')).to.exist;
// expect(maskBr.currency(123)).to.exist;
});
it('PIS/PASEP', function () {
var pispasep = '12312345121';
chai_1.expect(index_1.maskBr.pispasep(pispasep)).to.be.equal('123.12345.12-1');
testGeneric('pispasep');
});
it('PLACA', function () {
var placa = 'ABC1234';
chai_1.expect(index_1.maskBr.placa(placa)).to.be.equal('ABC-1234');
testGeneric('placa');
chai_1.expect(index_1.maskBr.placa('123')).to.exist;
});
it('Processos', function () {
// const processo = '000001001520081000000';
// expect(maskBr.processo(processo)).to.be.equal('00000100-15.2008.100.0000');
// testGeneric('processo');
chai_1.expect(index_1.maskBr.processo('123')).to.exist;
});
it('Renavam', function () {
testGeneric('renavam');
});
// // it('Time', () => {
// // const time = fakerBr.time();
// // expect(validateBr.time(time)).to.be.true;
// // });
// // it('Titulo', () => {
// // const titulo = fakerBr.titulo();
// // expect(validateBr.titulo(titulo)).to.be.true;
// // });
// it('Others', () => {
// // const currency = fakerBr.currency();
// // expect(validateBr.currency(currency)).to.be.true;
// // const inscricaoestadual = fakerBr.inscricaoestadual();
// // expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// // const percentage = fakerBr.percentage();
// // expect(validateBr.percentage(percentage)).to.be.true;
it('RG MG', function () {
var rg = 'mg11164324';
chai_1.expect(index_1.maskBr.rg(rg)).to.be.equal('mg-11.164.324');
testGeneric('rg');
chai_1.expect(index_1.maskBr.rg('123')).to.exist;
});
it('Telefone', function () {
var telefone = '3135003500';
chai_1.expect(index_1.maskBr.telefone(telefone)).to.be.equal('(31) 3500-3500');
// testGeneric('telefone');
chai_1.expect(index_1.maskBr.telefone('123')).to.exist;
});
it('Telefone 9 Digito', function () {
var telefone = '31988886565';
chai_1.expect(index_1.maskBr.telefone(telefone)).to.be.equal('(31) 98888-6565');
});
// it('Time', () => {
// const time = fakerBr.time();
// expect(validateBr.time(time)).to.be.true;
// });
it('Titulo', function () {
var titulo = index_1.fakerBr.titulo();
chai_1.expect(index_1.validateBr.titulo(titulo)).to.be.true;
testGeneric('titulo');
chai_1.expect(index_1.maskBr.titulo('123')).to.exist;
});
it('Others', function () {
// const currency = fakerBr.currency();
// expect(validateBr.currency(currency)).to.be.true;
// const inscricaoestadual = fakerBr.inscricaoestadual();
// expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// const percentage = fakerBr.percentage();
// expect(validateBr.percentage(percentage)).to.be.true;
});
});
//# sourceMappingURL=mask.js.map

@@ -49,8 +49,16 @@ "use strict";

});
it('Percentage', function () {
// context('Percentage', () => {
// it('Pass when valid', () => {
// expect(validateBr.percentage('10')).to.be.true;
// });
// it('Error when not valid', () => {
// expect(validateBr.percentage('1234')).to.be.false;
// });
// });
context('PIS/PASEP', function () {
it('Pass when valid', function () {
chai_1.expect(index_1.validateBr.percentage('10')).to.be.true;
chai_1.expect(index_1.validateBr.pispasep('103.12345.12-1')).to.be.true;
});
it('Error when not valid', function () {
chai_1.expect(index_1.validateBr.percentage('1234')).to.be.false;
chai_1.expect(index_1.validateBr.pispasep('1234')).to.be.false;
});

@@ -57,0 +65,0 @@ });

import * as utils from './src/utils';
import {
valida_cep, validate_cnpj, validate_cpf, validate_telefone,
validate_currency, validate_percentage, validate_rg, validate_time, validate_titulo, validate_processo, validate_celular, validate_renavam, validate_number
} from './src/validate';
import { validar } from './src/inscricaoestadual';
export { validateBr } from './src/validate';
import * as faker from './src/faker';
import * as mask from './src/mask';
import { MASKS } from './src/mask';
import { PLACAS_RANGE, validate_placa } from './src/placa';
import { PLACAS_RANGE } from './src/placa';
import { ESTADOS } from './src/estados';
export const validateBr = {
cep: valida_cep,
cnpj: validate_cnpj,
cpf: validate_cpf,
currency: validate_currency,
number: validate_number,
inscricaoestadual: validar,
percentage: validate_percentage,
rg: validate_rg,
placa: validate_placa,
renavam: validate_renavam,
telefone: validate_telefone,
celular: validate_celular,
time: validate_time,
titulo: validate_titulo,
processo: validate_processo
};
export const utilsBr = {

@@ -32,0 +10,0 @@ ...utils,

{
"name": "js-brasil",
"version": "1.4.4",
"version": "1.4.5",
"description": "Javascript Utils para Brasil (cpf, cnpj...)",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -151,9 +151,12 @@ # js-brasil

* CPF - - http://geradorbrasileiro.com/cpf.html
* CNH - - http://geradorbrasileiro.com/cnh.html
* Celular - http://geradorbrasileiro.com/celular.html
* Inscricao Estadual - - http://geradorbrasileiro.com/inscricaoestadual.html Todos os estados do Brasil
* RG - http://geradorbrasileiro.com/rg.html
* Placa de carro - http://geradorbrasileiro.com/placa.html
* PIS/PASEP - http://geradorbrasileiro.com/pis.html
* Processo da justiça - http://geradorbrasileiro.com/processo.html
* Telefone - http://geradorbrasileiro.com/telefone.html
* Celular - http://geradorbrasileiro.com/celular.html
* Título de Eleitor - http://geradorbrasileiro.com/titulo.html
* Processo da justiça - http://geradorbrasileiro.com/processo.html
* RENAVAM - http://geradorbrasileiro.com/renavam.html
* Outros: currency, percentage, time (data/hora), number - http://geradorbrasileiro.com/others.html

@@ -160,0 +163,0 @@

@@ -119,2 +119,3 @@ import { ESTADOS_SIGLA } from './estados';

percentage: makeGeneric(MASKS['percentage']),
pispasep: makeGeneric(MASKS['pispasep']),
placa: () => {

@@ -121,0 +122,0 @@ let placa: any;

@@ -14,22 +14,2 @@ import { isArray, processCaretTraps } from './utils';

},
rg: {
text: 'AA-00.000.000',
textMask: [/[A-Za-z]/, /[A-Za-z]/, '-', /\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/]
},
telefone: {
text: '(00) 0000-0000',
textMask: ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
textMaskFunction: function mask(userInput: any) {
const numbers = userInput.match(/\d/g);
let numberLength = 0;
if (numbers) {
numberLength = numbers.join('').length;
}
if (!userInput || numberLength > 10) {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
} else {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
}
},
celular: {

@@ -39,2 +19,6 @@ text: '(00) 00000-0000',

},
creditcard: {
text: '0000 0000 0000 0000 00/00 000',
textMask: [/\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, '0', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, '/', /\d/, /\d/, ' ', /\d/, /\d/, /\d/]
},
cep: {

@@ -44,7 +28,2 @@ text: '00.000-000',

},
inscricaoestadual: IEMASKS,
time: {
text: '00:00',
textMask: [/\d/, /\d/, ':', /\d/, /\d/]
},
currency: {

@@ -62,2 +41,3 @@ text: '0.000,00',

},
inscricaoestadual: IEMASKS,
number: {

@@ -75,2 +55,6 @@ text: '0.000,00',

},
pispasep: {
text: '000.00000.00-0',
textMask: [/\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, '-', /\d/]
},
percentage: {

@@ -92,6 +76,2 @@ text: '00,00%',

},
titulo: {
text: '0000.0000.0000',
textMask: [/\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/]
},
processo: {

@@ -101,2 +81,6 @@ text: '0000000-00.0000.AAA.0000',

},
rg: {
text: 'AA-00.000.000',
textMask: [/[A-Za-z]/, /[A-Za-z]/, '-', /\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/]
},
renavam: {

@@ -118,6 +102,26 @@ text: '0000000000-00',

},
creditcard: {
text: '0000 0000 0000 0000 00/00 000',
textMask: [/\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, '0', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, '/', /\d/, /\d/, ' ', /\d/, /\d/, /\d/]
telefone: {
text: '(00) 0000-0000',
textMask: ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
textMaskFunction: function mask(userInput: any) {
const numbers = userInput.match(/\d/g);
let numberLength = 0;
if (numbers) {
numberLength = numbers.join('').length;
}
if (!userInput || numberLength > 10) {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
} else {
return ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
}
},
titulo: {
text: '0000.0000.0000',
textMask: [/\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/]
},
time: {
text: '00:00',
textMask: [/\d/, /\d/, ':', /\d/, /\d/]
},
utils: {

@@ -231,2 +235,3 @@ numberToString: (n: number) => {

},
pispasep: makeGeneric('pispasep'),
placa: makeGeneric('placa'),

@@ -233,0 +238,0 @@ renavam: makeGeneric('renavam'),

import { modulo11 } from "./utils";
import { validar } from "./inscricaoestadual";
import { validate_placa } from "./placa";

@@ -218,2 +220,7 @@ // http://www.geradorcnpj.com/javascript-validar-cnpj.htm

export function validate_pispasep(number: string) {
const regex = /^\d{3}\.\d{5}\.\d{2}\-\d{1}$/;
return regex.test(number);
}
export function validate_number(number: string) {

@@ -337,2 +344,21 @@ const regex = /^\d+(?:\.\d{0,2})$/;

}
}
}
export const validateBr = {
cep: valida_cep,
celular: validate_celular,
cnpj: validate_cnpj,
cpf: validate_cpf,
currency: validate_currency,
number: validate_number,
inscricaoestadual: validar,
percentage: validate_percentage,
pispasep: validate_pispasep,
placa: validate_placa,
processo: validate_processo,
renavam: validate_renavam,
rg: validate_rg,
telefone: validate_telefone,
time: validate_time,
titulo: validate_titulo
};

@@ -19,3 +19,6 @@ import { fakerBr, validateBr } from '../index';

it('Faker celular', () => {
const celular = fakerBr.celular();
expect(validateBr.celular(celular)).to.be.true;
});
it('Faker CEP', () => {

@@ -33,2 +36,8 @@ const cep = fakerBr.cep();

});
it('Faker Currency', () => {
// const currency = fakerBr.currency();
// expect(validateBr.currency(currency)).to.be.true;
const currencyNumber = fakerBr.currencyNumber();
expect(validateBr.currency(currencyNumber)).to.be.true;
});
it('Faker RG', () => {

@@ -38,2 +47,10 @@ const rg = fakerBr.rg();

});
it('Faker RENAVAM', () => {
const renavam = fakerBr.renavam();
expect(validateBr.renavam(renavam)).to.be.true;
});
it('Faker PIS/PASEP', () => {
const pispasep = fakerBr.pispasep();
expect(validateBr.pispasep(pispasep)).to.be.true;
});
it('Faker PLACA', () => {

@@ -47,6 +64,3 @@ const placa = fakerBr.placa();

});
it('Faker celular', () => {
const celular = fakerBr.celular();
expect(validateBr.celular(celular)).to.be.true;
});
// it('Faker Time', () => {

@@ -56,2 +70,8 @@ // const time = fakerBr.time();

// });
// const inscricaoestadual = fakerBr.inscricaoestadual();
// expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// const percentage = fakerBr.percentage();
// expect(validateBr.percentage(percentage)).to.be.true;
it('Faker Titulo', () => {

@@ -62,18 +82,2 @@ const titulo = fakerBr.titulo();

it('Faker Moeda', () => {
const currency = fakerBr.currency();
const currencyNumber = fakerBr.currencyNumber();
// expect(validateBr.currency(currency)).to.be.true;
expect(validateBr.currency(currencyNumber)).to.be.true;
});
it('Faker Others', () => {
// const inscricaoestadual = fakerBr.inscricaoestadual();
// expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// const percentage = fakerBr.percentage();
// expect(validateBr.percentage(percentage)).to.be.true;
});
});

@@ -14,30 +14,11 @@ import { maskBr, fakerBr, validateBr } from '../index';

it('To generate any data', () => {
expect(maskBr.cep('123')).to.exist;
expect(maskBr.cnpj('123')).to.exist;
expect(maskBr.cpf('123')).to.exist;
// expect(maskBr.currency('123')).to.exist;
// expect(maskBr.currency(123)).to.exist;
expect(maskBr.inscricaoestadual('mg', '123')).to.exist;
expect(maskBr.percentage('123')).to.exist;
expect(maskBr.rg('123')).to.exist;
expect(maskBr.placa('123')).to.exist;
expect(maskBr.telefone('123')).to.exist;
expect(maskBr.time('123')).to.exist;
expect(maskBr.titulo('123')).to.exist;
expect(maskBr.processo('123')).to.exist;
});
it('Generic Testing with Faker , Mask and Validate', () => {
testGeneric('cnpj');
// testGeneric('currency');
// testGeneric('inscricaoestadual');
// testGeneric('percentage');
testGeneric('rg');
// testGeneric('telefone');
// testGeneric('time');
testGeneric('titulo');
// testGeneric('processo');
});
it('CEP', () => {

@@ -47,2 +28,3 @@ const cep = '30456098';

testGeneric('cep');
expect(maskBr.cep('123')).to.exist;
});

@@ -52,2 +34,4 @@ it('CNPJ', () => {

expect(maskBr.cnpj(cnpj)).to.be.equal('83.529.443/1831-82');
expect(maskBr.cnpj('123')).to.exist;
testGeneric('cnpj');
});

@@ -58,26 +42,5 @@ it('CPF', () => {

testGeneric('cpf');
expect(maskBr.cpf('123')).to.exist;
});
it('RG MG', () => {
const rg = 'mg11164324';
expect(maskBr.rg(rg)).to.be.equal('mg-11.164.324');
});
it('PLACA', () => {
const placa = 'ABC1234';
expect(maskBr.placa(placa)).to.be.equal('ABC-1234');
testGeneric('placa');
});
it('Telefone', () => {
const telefone = '3135003500';
expect(maskBr.telefone(telefone)).to.be.equal('(31) 3500-3500');
});
it('Telefone 9 Digito', () => {
const telefone = '31988886565';
expect(maskBr.telefone(telefone)).to.be.equal('(31) 98888-6565');
});
it('Processos', () => {
const processo = '000001001520081000000';
// expect(maskBr.processo(processo)).to.be.equal('00000100-15.2008.100.0000');
});
it('Moeda', () => {
it('Currency', () => {
const currency = 'R$ 5.103,94';

@@ -99,4 +62,25 @@ const currencyText = '5.103,94';

expect(maskBr.currency(currencyNumberMany)).to.be.equal('R$ 5.103,94');
// testGeneric('currency');
// expect(maskBr.currency('123')).to.exist;
// expect(maskBr.currency(123)).to.exist;
});
it('PIS/PASEP', () => {
const pispasep = '12312345121';
expect(maskBr.pispasep(pispasep)).to.be.equal('123.12345.12-1');
testGeneric('pispasep');
});
it('PLACA', () => {
const placa = 'ABC1234';
expect(maskBr.placa(placa)).to.be.equal('ABC-1234');
testGeneric('placa');
expect(maskBr.placa('123')).to.exist;
});
it('Processos', () => {
// const processo = '000001001520081000000';
// expect(maskBr.processo(processo)).to.be.equal('00000100-15.2008.100.0000');
// testGeneric('processo');
expect(maskBr.processo('123')).to.exist;
});
it('Renavam', () => {

@@ -106,21 +90,41 @@ testGeneric('renavam');

// // it('Time', () => {
// // const time = fakerBr.time();
// // expect(validateBr.time(time)).to.be.true;
// // });
// // it('Titulo', () => {
// // const titulo = fakerBr.titulo();
// // expect(validateBr.titulo(titulo)).to.be.true;
// // });
// it('Others', () => {
// // const currency = fakerBr.currency();
// // expect(validateBr.currency(currency)).to.be.true;
it('RG MG', () => {
const rg = 'mg11164324';
expect(maskBr.rg(rg)).to.be.equal('mg-11.164.324');
testGeneric('rg');
expect(maskBr.rg('123')).to.exist;
});
// // const inscricaoestadual = fakerBr.inscricaoestadual();
// // expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
it('Telefone', () => {
const telefone = '3135003500';
expect(maskBr.telefone(telefone)).to.be.equal('(31) 3500-3500');
// testGeneric('telefone');
expect(maskBr.telefone('123')).to.exist;
});
it('Telefone 9 Digito', () => {
const telefone = '31988886565';
expect(maskBr.telefone(telefone)).to.be.equal('(31) 98888-6565');
});
// // const percentage = fakerBr.percentage();
// // expect(validateBr.percentage(percentage)).to.be.true;
// it('Time', () => {
// const time = fakerBr.time();
// expect(validateBr.time(time)).to.be.true;
// });
it('Titulo', () => {
const titulo = fakerBr.titulo();
expect(validateBr.titulo(titulo)).to.be.true;
testGeneric('titulo');
expect(maskBr.titulo('123')).to.exist;
});
it('Others', () => {
// const currency = fakerBr.currency();
// expect(validateBr.currency(currency)).to.be.true;
// const inscricaoestadual = fakerBr.inscricaoestadual();
// expect(validateBr.inscricaoestadual(inscricaoestadual)).to.be.true;
// const percentage = fakerBr.percentage();
// expect(validateBr.percentage(percentage)).to.be.true;
});
});

@@ -55,8 +55,17 @@ import { validateBr } from '../index';

it('Percentage', () => {
// context('Percentage', () => {
// it('Pass when valid', () => {
// expect(validateBr.percentage('10')).to.be.true;
// });
// it('Error when not valid', () => {
// expect(validateBr.percentage('1234')).to.be.false;
// });
// });
context('PIS/PASEP', () => {
it('Pass when valid', () => {
expect(validateBr.percentage('10')).to.be.true;
expect(validateBr.pispasep('103.12345.12-1')).to.be.true;
});
it('Error when not valid', () => {
expect(validateBr.percentage('1234')).to.be.false;
expect(validateBr.pispasep('1234')).to.be.false;
});

@@ -63,0 +72,0 @@ });

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 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 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

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