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.2.0 to 1.2.1

15

dist/src/inscricaoestadual.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
/**
* BASED ON https://github.com/gammasoft/ie/
*/
Object.defineProperty(exports, "__esModule", { value: true });
var funcoesGenerate = {

@@ -441,6 +442,6 @@ ac: function (valor) {

if (estado !== '' && !(estado in funcoes)) {
throw new Error('estado não é válido');
return new Error('estado não é válido');
}
if (eIndefinido(ie)) {
throw new Error('ie deve ser fornecida');
return new Error('ie deve ser fornecida');
}

@@ -451,4 +452,7 @@ if (Array.isArray(ie)) {

if (typeof ie !== 'string') {
throw new Error('ie deve ser string ou array de strings');
return new Error('ie deve ser string ou array de strings');
}
if (!utils_1.allNumbersAreSame(ie)) {
return new Error('ie com todos dígitos iguais');
}
if (ie.match(/^ISENTO$/i)) {

@@ -651,2 +655,5 @@ return true;

}
if (!base) {
base = primeiros(valor);
}
var digito = substracaoPor11SeMaiorQue2CasoContrario0(mod(base));

@@ -653,0 +660,0 @@ return base + digito;

@@ -46,2 +46,21 @@ "use strict";

};
/**
*
* @param input
* ^ - Match line start
(\d) - match first digit and capture it in back reference #1 i.e. \1
(?!..) is a negative lookahead
(?!\1+$) means disallow the match if first digit is followed by same digit (captured group) till end.
\d{11}$ match next 11 digit followed by line end
*/
function allNumbersAreSame(input) {
input = getAllDigits(input);
var reg = new RegExp('^(\\d)(?!\\1+$)\\d{' + (input.length - 1) + '}$');
return reg.test(input);
}
exports.allNumbersAreSame = allNumbersAreSame;
function getAllDigits(input) {
return input.match(/\d/g).join("");
}
exports.getAllDigits = getAllDigits;
//# sourceMappingURL=utils.js.map

@@ -24,2 +24,8 @@ "use strict";

});
it('Inscricao Estadual', function () {
chai_1.expect(index_1.validateBr.inscricaoestadual('862.445.372/2351', 'mg')).to.be.true;
chai_1.expect(index_1.validateBr.inscricaoestadual('094.290.083', 'sc')).to.be.true;
chai_1.expect(index_1.validateBr.inscricaoestadual('094.290.0839', 'sc')).to.be.false;
chai_1.expect(index_1.validateBr.inscricaoestadual('111111111111', 'mg').message).to.be.equal('ie com todos dígitos iguais');
});
it('PLACA', function () {

@@ -26,0 +32,0 @@ chai_1.expect(index_1.validateBr.placa('ABC1234')).to.be.true;

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

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

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

import { allNumbersAreSame } from "./utils";

@@ -562,7 +563,7 @@ /**

if (estado !== '' && !(estado in funcoes)) {
throw new Error('estado não é válido');
return new Error('estado não é válido');
}
if (eIndefinido(ie)) {
throw new Error('ie deve ser fornecida');
return new Error('ie deve ser fornecida');
}

@@ -575,5 +576,9 @@

if (typeof ie !== 'string') {
throw new Error('ie deve ser string ou array de strings');
return new Error('ie deve ser string ou array de strings');
}
if(!allNumbersAreSame(ie)){
return new Error('ie com todos dígitos iguais');
}
if (ie.match(/^ISENTO$/i)) {

@@ -593,2 +598,3 @@ return true;

return false;

@@ -789,6 +795,8 @@ }

}
if (eIndefinido(base)) {
base = primeiros(valor);
}
if(!base){
base = primeiros(valor);
}

@@ -795,0 +803,0 @@ const digito = substracaoPor11SeMaiorQue2CasoContrario0(mod(base));

@@ -35,3 +35,3 @@ export function isPresent(obj: any): boolean {

export const modulo11 = (string, size, mod)=>{
export const modulo11 = (string, size, mod) => {
let soma = 0;

@@ -48,2 +48,21 @@ for (let i = 1; i <= size; i++) {

return resto;
}
/**
*
* @param input
* ^ - Match line start
(\d) - match first digit and capture it in back reference #1 i.e. \1
(?!..) is a negative lookahead
(?!\1+$) means disallow the match if first digit is followed by same digit (captured group) till end.
\d{11}$ match next 11 digit followed by line end
*/
export function allNumbersAreSame(input) {
input = getAllDigits(input);
const reg = new RegExp('^(\\d)(?!\\1+$)\\d{' + (input.length - 1) + '}$');
return reg.test(input);
}
export function getAllDigits(input) {
return input.match(/\d/g).join("");
}

@@ -27,2 +27,10 @@ import { validateBr } from '../index';

it('Inscricao Estadual', () => {
expect(validateBr.inscricaoestadual('862.445.372/2351', 'mg')).to.be.true;
expect(validateBr.inscricaoestadual('094.290.083', 'sc')).to.be.true;
expect(validateBr.inscricaoestadual('094.290.0839', 'sc')).to.be.false;
expect(validateBr.inscricaoestadual('111111111111', 'mg').message).to.be.equal('ie com todos dígitos iguais');
});
it('PLACA', () => {

@@ -29,0 +37,0 @@ expect(validateBr.placa('ABC1234')).to.be.true;

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