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.3 to 1.3.0

17

dist/src/mask.js

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

}
return (n + '').replace('.', ',');
return (n.toString()).replace('.', ',');
}

@@ -151,8 +151,8 @@ }

time: makeGeneric('time'),
currency: function (currencyValue) {
if (!currencyValue) {
currency: function (currencyValueInput) {
if (!currencyValueInput) {
return '';
}
if (!currencyValue.split) {
currencyValue += '';
var currencyValue = currencyValueInput.toString();
if (typeof currencyValueInput === 'number') {
currencyValue = currencyValue.replace('.', ',');

@@ -162,7 +162,8 @@ }

var mask = exports.MASKS.currency.textMask(vals[0]);
var decimals = vals.length > 1 ? vals[1] + '' : '00';
var decimals = vals.length > 1 ? vals[1].toString() : '00';
if (decimals.length > 2) {
decimals = decimals.substring(0, 2);
}
return conformToMask(currencyValue, mask, { guide: false }).conformedValue + ',' + decimals;
var finalValue = conformToMask(currencyValue, mask, { guide: false }).conformedValue + ',' + decimals;
return finalValue;
},

@@ -179,3 +180,3 @@ number: function (numberValue) {

var mask = exports.MASKS.number.textMask(vals[0]);
var decimals = vals.length > 1 ? vals[1] + '' : '00';
var decimals = vals.length > 1 ? vals[1].toString() : '00';
if (decimals.length > 2) {

@@ -182,0 +183,0 @@ decimals = decimals.substring(0, 2);

@@ -141,10 +141,12 @@ "use strict";

function validate_placa(placa) {
var placaClean = placa.replace(/-/g, '').toUpperCase();
var placaClean = placa.toString();
placaClean = placaClean.replace(/-/g, '').toUpperCase();
var exp = /[A-Za-z]{3}\-\d{4}/;
var expClean = /[A-Za-z]{3}\d{4}/;
// const letters = placa.substr(0, 3).toUpperCase();
if (!exp.test(placa) && !expClean.test(placaClean)) {
var placaString = placa.toString();
if (!exp.test(placaString) && !expClean.test(placaClean)) {
return false;
}
var found = placa >= exports.PLACAS_INVALID.start && placa <= exports.PLACAS_INVALID.end;
var found = placaString >= exports.PLACAS_INVALID.start && placaString <= exports.PLACAS_INVALID.end;
if (found) {

@@ -151,0 +153,0 @@ return false;

@@ -55,6 +55,8 @@ "use strict";

*/
function allNumbersAreSame(input) {
input = getAllDigits(input);
var reg = new RegExp('^(\\d)(?!\\1+$)\\d{' + (input.length - 1) + '}$');
return reg.test(input);
function allNumbersAreSame(inputValue) {
var input = getAllDigits(inputValue);
if (typeof input === 'string') {
var reg = new RegExp('^(\\d)(?!\\1+$)\\d{' + (input.length - 1) + '}$');
return reg.test(input);
}
}

@@ -61,0 +63,0 @@ exports.allNumbersAreSame = allNumbersAreSame;

@@ -137,6 +137,7 @@ "use strict";

function cep_ranges(cep) {
cep = cep.replace(/[^\d]+/g, '');
cep = (cep.toString()).replace(/[^\d]+/g, '');
cep = parseInt(cep, 10);
var cepString = cep.toString();
var found = Object.keys(exports.CEPRange).find(function (estado) {
var r = new RegExp(exports.CEPRange[estado]).test(cep);
var r = new RegExp(exports.CEPRange[estado]).test(cepString);
if (r) {

@@ -190,3 +191,4 @@ return true;

var expression = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/;
return expression.test(time.value);
var value = time.toString();
return expression.test(value);
}

@@ -196,3 +198,3 @@ exports.validate_time = validate_time;

var regex = /^\d+(?:\.\d{0,2})$/;
return regex.test(currency);
return regex.test(currency.toString());
}

@@ -199,0 +201,0 @@ exports.validate_currency = validate_currency;

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

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

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

const makeGeneric = (val, options = null) => {
const makeGeneric = (val: any, options = null) => {
return () => {

@@ -13,3 +13,3 @@ if (!val.textMask || !val.textMask.map) {

}
const newData = val.textMask.map((c, index) => {
const newData = val.textMask.map((c: string | any[], index: string | number) => {
if (options && options[index]) {

@@ -40,3 +40,3 @@ return options[index]();

function rand(length, ...ranges) {
function rand(length: number, ...ranges: (any[] | { charCodeAt: (arg0: number) => void; }[])[]) {
var str = ""; // the string (initialized to "")

@@ -76,3 +76,3 @@ while (length--) { // repeat this length of times

cep: makeGeneric(MASKS['cep']),
cepState: (state) => {
cepState: (state: string | number) => {
return randexp(CEPRange[state]);

@@ -124,3 +124,3 @@ },

placa: () => {
let placa;
let placa: any;
do {

@@ -127,0 +127,0 @@ placa = makeGeneric(MASKS['placa'])();

@@ -9,3 +9,3 @@ import { allNumbersAreSame } from "./utils";

const funcoesGenerate = {
ac: function (valor) {
ac: function (valor: any) {
if (tamanhoNaoE(valor, 13)) {

@@ -27,3 +27,3 @@ return false;

am: function (valor) {
am: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -36,3 +36,3 @@ return false;

al: function (valor) {
al: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -57,3 +57,3 @@ return false;

const base = primeiros(valor);
const base: any = primeiros(valor);

@@ -69,3 +69,3 @@ let resto = mod(base) * 10;

ap: function (valor) {
ap: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -79,5 +79,5 @@ return false;

const base = primeiros(valor);
const base: any = primeiros(valor);
let p, d;
let p: number, d: number;

@@ -97,3 +97,3 @@ if (entre(base, 3000001, 3017000)) {

let digito;
let digito: number;
if (resto === 1) {

@@ -110,3 +110,3 @@ digito = 0;

ba: function (valor) {
ba: function (valor: any) {
if (tamanhoNaoE(valor, 8) && tamanhoNaoE(valor)) {

@@ -116,4 +116,4 @@ return false;

const base = primeiros(valor, valor.length - 2);
let primeiroDigito, segundoDigito;
const base: any = primeiros(valor, valor.length - 2);
let primeiroDigito: number, segundoDigito: number;

@@ -123,3 +123,3 @@ const segundoMultiplicador = serie(2, 7);

let primeiroResto, segundoResto;
let primeiroResto: number, segundoResto: number;
let digitoComparacao = valor.substring(0, 1);

@@ -150,3 +150,3 @@

ce: function (valor) {
ce: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -158,3 +158,3 @@ return false;

df: function (valor) {
df: function (valor: any) {
if (tamanhoNaoE(valor, 13)) {

@@ -168,3 +168,3 @@ return false;

const base = primeiros(valor, 11);
const base: any = primeiros(valor, 11);

@@ -177,6 +177,6 @@ const primeiro = substracaoPor11SeMaiorQue2CasoContrario0(mod(base));

es: function (valor) {
es: function (valor: any) {
return calculoTrivialGenerate(valor);
},
go: function (valor) {
go: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -190,3 +190,3 @@ return false;

const base = primeiros(valor);
const base: any = primeiros(valor);

@@ -198,3 +198,3 @@ if (base === '11094402') {

const resto = mod(base);
let digito;
let digito: number;

@@ -215,3 +215,3 @@ if (resto === 0) {

},
ma: function (valor) {
ma: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -228,3 +228,3 @@ return false;

mg: function (valor) {
mg: function (valor: any) {
if (tamanhoNaoE(valor, 13)) {

@@ -249,3 +249,3 @@ return false;

let primeiro = ((Math.floor(produtorioLiteral / 10) + 1) * 10) - produtorioLiteral;
let primeiro: any = ((Math.floor(produtorioLiteral / 10) + 1) * 10) - produtorioLiteral;
if (primeiro === 10) {

@@ -260,3 +260,3 @@ primeiro = 0;

ms: function (valor) {
ms: function (valor: any) {
if (naoComecaCom(valor, '28')) {

@@ -268,3 +268,3 @@ return false;

},
mt: function (valor) {
mt: function (valor: any) {
if (tamanhoNaoE(valor, 11) && tamanhoNaoE(valor)) {

@@ -277,3 +277,3 @@ return false;

},
pa: function (valor) {
pa: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -290,3 +290,3 @@ return false;

pb: function (valor) {
pb: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -299,4 +299,4 @@ return false;

pe: function (valor) {
const base = valor.substring(0, valor.length - 2);
pe: function (valor: any) {
const base: any = valor.substring(0, valor.length - 2);

@@ -312,7 +312,7 @@ const restoPrimeiro = mod(base);

pi: function (valor) {
pi: function (valor: any) {
return calculoTrivialGenerate(valor);
},
pr: function (valor) {
pr: function (valor: any) {
if (tamanhoNaoE(valor, 10)) {

@@ -332,3 +332,3 @@ return false;

},
rj: function (valor) {
rj: function (valor: any) {
if (tamanhoNaoE(valor, 8)) {

@@ -344,3 +344,3 @@ return false;

rn: function (valor) {
rn: function (valor: any) {
if (tamanhoNaoE(valor) && tamanhoNaoE(valor, 10)) {

@@ -366,4 +366,4 @@ return false;

},
ro: function (valor) {
let base, digito, resultadoMod;
ro: function (valor: any) {
let base: any, digito: number, resultadoMod: number;

@@ -385,3 +385,3 @@ if (tamanhoE(valor, 9)) {

},
rr: function (valor) {
rr: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -401,3 +401,3 @@ return false;

rs: function (valor) {
rs: function (valor: any) {
if (tamanhoNaoE(valor, 10)) {

@@ -411,7 +411,7 @@ return false;

sc: function (valor) {
sc: function (valor: any) {
return calculoTrivialGenerate(valor);
},
se: function (valor) {
se: function (valor: any) {
if (tamanhoNaoE(valor)) {

@@ -424,6 +424,6 @@ return false;

sp: function (valor) {
sp: function (valor: any) {
valor = valor.toUpperCase();
let segundaBase;
let segundaBase: string;

@@ -459,3 +459,3 @@ if (valor.substr(0, 1) === 'P') {

to: function (valor) {
to: function (valor: any) {
if (tamanhoNaoE(valor) && tamanhoNaoE(valor, 11)) {

@@ -465,3 +465,3 @@ return false;

let base;
let base: any;

@@ -488,96 +488,96 @@ if (tamanhoE(valor, 11)) {

const funcoes = {
ac: function (valor) {
ac: function (valor: any) {
return valor === funcoesGenerate.ac(valor);
},
am: function (valor) {
am: function (valor: any) {
return valor === funcoesGenerate.am(valor);
},
al: function (valor) {
al: function (valor: any) {
return valor === funcoesGenerate.al(valor);
},
ap: function (valor) {
ap: function (valor: any) {
return valor === funcoesGenerate.ap(valor);
},
ba: function (valor) {
ba: function (valor: any) {
return valor === funcoesGenerate.ba(valor);
},
ce: function (valor) {
ce: function (valor: any) {
return valor === funcoesGenerate.ce(valor);
},
es: function (valor) {
es: function (valor: any) {
return valor === funcoesGenerate.es(valor);
},
go: function (valor) {
go: function (valor: any) {
return valor === funcoesGenerate.go(valor);
},
ma: function (valor) {
ma: function (valor: any) {
return valor === funcoesGenerate.ma(valor);
},
mg: function (valor) {
mg: function (valor: any) {
return valor === funcoesGenerate.mg(valor);
},
ms: function (valor) {
ms: function (valor: any) {
return valor === funcoesGenerate.ms(valor);
},
mt: function (valor) {
mt: function (valor: any) {
return valor === funcoesGenerate.mt(valor);
},
pa: function (valor) {
pa: function (valor: any) {
return valor === funcoesGenerate.pa(valor);
},
pb: function (valor) {
pb: function (valor: any) {
return valor === funcoesGenerate.pb(valor);
},
pe: function (valor) {
pe: function (valor: any) {
return valor === funcoesGenerate.pe(valor);
},
pi: function (valor) {
pi: function (valor: any) {
return valor === funcoesGenerate.pi(valor);
},
pr: function (valor) {
pr: function (valor: any) {
return valor === funcoesGenerate.pr(valor);
},
rj: function (valor) {
rj: function (valor: any) {
return valor === funcoesGenerate.rj(valor);
},
rn: function (valor) {
rn: function (valor: any) {
return valor === funcoesGenerate.rn(valor);
},
ro: function (valor) {
ro: function (valor: any) {
return valor === funcoesGenerate.ro(valor);
},
rr: function (valor) {
rr: function (valor: any) {
return valor === funcoesGenerate.rr(valor);
},
rs: function (valor) {
rs: function (valor: any) {
return valor === funcoesGenerate.rs(valor);
},
sc: function (valor) {
sc: function (valor: any) {
return valor === funcoesGenerate.sc(valor);
},
se: function (valor) {
se: function (valor: any) {
return valor === funcoesGenerate.se(valor);
},
sp: function (valor) {
sp: function (valor: string | boolean) {
return valor === funcoesGenerate.sp(valor);
},
to: function (valor) {
to: function (valor: any) {
return valor === funcoesGenerate.to(valor);

@@ -590,3 +590,3 @@ },

export function validar(ie, estado) {
export function validar(ie: string, estado: any) {
if (eIndefinido(estado) || estado === null) {

@@ -716,4 +716,4 @@ estado = '';

textMask: [/\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, '-', /\d/],
textMaskFunction: function mask(userInput) {
const numbers = userInput.match(/\d/g);
textMaskFunction: function mask(userInput: { match: (arg0: RegExp) => void; }) {
const numbers: any = userInput.match(/\d/g);
let numberLength = 0;

@@ -762,7 +762,7 @@ if (numbers) {

function eIndefinido(objeto) {
function eIndefinido(objeto: any) {
return typeof objeto === typeof undefined;
}
function tamanhoNaoE(string, tamanho = 9) {
function tamanhoNaoE(string: { length: number; }, tamanho = 9) {
if (eIndefinido(tamanho)) {

@@ -775,7 +775,7 @@ tamanho = 9;

function tamanhoE(string, tamanho) {
function tamanhoE(string: any[], tamanho: number) {
return !tamanhoNaoE(string, tamanho);
}
function serie(de, ate) {
function serie(de: number, ate: number) {
const resultado = [];

@@ -790,3 +790,3 @@

function primeiros(string, quantidade = 8) {
function primeiros(string: any, quantidade = 8) {
if (eIndefinido(quantidade)) {

@@ -799,7 +799,7 @@ quantidade = 8;

function substracaoPor11SeMaiorQue2CasoContrario0(valor) {
function substracaoPor11SeMaiorQue2CasoContrario0(valor: number) {
return valor < 2 ? 0 : 11 - valor;
}
function mod(valor, multiplicadores = serie(2, 9), divisor = 11) {
function mod(valor: string, multiplicadores = serie(2, 9), divisor = 11) {
if (eIndefinido(divisor)) {

@@ -815,3 +815,3 @@ divisor = 11;

return valor.split('').reduceRight(function (anterior, atual) {
return valor.split('').reduceRight(function (anterior: number, atual: string) {
if (i > multiplicadores.length - 1) {

@@ -825,3 +825,3 @@ i = 0;

function calculoTrivial(valor, base = null, validarTamanho = null) {
function calculoTrivial(valor: any, base = null, validarTamanho = null) {
return valor === calculoTrivialGenerate(valor);

@@ -831,3 +831,3 @@ }

function calculoTrivialGenerate(valor, base = null, validarTamanho = null) {
function calculoTrivialGenerate(valor: any, base = null, validarTamanho = null) {
if (!validarTamanho && tamanhoNaoE(valor)) {

@@ -848,7 +848,7 @@ return false;

function naoComecaCom(string, valor) {
function naoComecaCom(string: any, valor: string) {
return string.substring(0, valor.length) !== valor;
}
function entre(valor, limiteInferior, limiteSuperior) {
function entre(valor: string | number, limiteInferior: number, limiteSuperior: number) {
if (typeof valor === 'string') {

@@ -862,3 +862,3 @@ valor = parseInt(valor, 10);

function lookup(ie) {
function lookup(ie: any) {
const resultado = [];

@@ -865,0 +865,0 @@

@@ -21,3 +21,3 @@ import { isArray, processCaretTraps } from './utils';

textMask: ['(', /[1-9]/, /\d/, ')', ' ', /[1-9]/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
textMaskFunction: function mask(userInput) {
textMaskFunction: function mask(userInput: any) {
const numbers = userInput.match(/\d/g);

@@ -99,3 +99,3 @@ let numberLength = 0;

textMask: [/\d/, /\d/, /\d/, /\d/, /\d/, /\d/, /\d/, /\d/, /\d/, /\d/, '-', /\d/],
textMaskFunction: function mask(userInput) {
textMaskFunction: function mask(userInput: any) {
const numbers = userInput.match(/\d/g);

@@ -114,7 +114,7 @@ let numberLength = 0;

utils: {
numberToString: (n) => {
numberToString: (n: number) => {
if (!n || typeof n === 'string') {
return n;
}
return (n + '').replace('.', ',');
return (n.toString()).replace('.', ',');
}

@@ -125,4 +125,4 @@ }

const makeGeneric = (key) => {
return (value) => {
const makeGeneric = (key: string) => {
return (value: string) => {
if (!value) {

@@ -151,3 +151,3 @@ return '';

celular: makeGeneric('celular'),
inscricaoestadual: (inscricaoestadualValue, estado) => {
inscricaoestadual: (inscricaoestadualValue: string, estado: string | number) => {
if (!inscricaoestadualValue || !estado || !MASKS.inscricaoestadual[estado] ||

@@ -164,8 +164,11 @@ !MASKS.inscricaoestadual[estado].textMask) {

time: makeGeneric('time'),
currency: (currencyValue) => {
if (!currencyValue) {
currency: (currencyValueInput: string | number) => {
if (!currencyValueInput) {
return '';
}
if (!currencyValue.split) {
currencyValue += '';
let currencyValue: string = currencyValueInput.toString();
if(typeof currencyValueInput === 'number'){
currencyValue = currencyValue.replace('.', ',');

@@ -176,3 +179,3 @@ }

const mask = MASKS.currency.textMask(vals[0]);
let decimals = vals.length > 1 ? vals[1] + '' : '00';
let decimals = vals.length > 1 ? vals[1].toString() : '00';
if (decimals.length > 2) {

@@ -182,3 +185,3 @@ decimals = decimals.substring(0, 2);

return conformToMask(
const finalValue = conformToMask(
currencyValue,

@@ -188,4 +191,6 @@ mask,

).conformedValue + ',' + decimals;
return finalValue
},
number: (numberValue) => {
number: (numberValue: string) => {
if (!numberValue) {

@@ -201,3 +206,3 @@ return '';

const mask = MASKS.number.textMask(vals[0]);
let decimals = vals.length > 1 ? vals[1] + '' : '00';
let decimals = vals.length > 1 ? vals[1].toString() : '00';
if (decimals.length > 2) {

@@ -213,3 +218,3 @@ decimals = decimals.substring(0, 2);

},
percentage: (percentageValue) => {
percentage: (percentageValue: string) => {
if (!percentageValue) {

@@ -504,5 +509,5 @@ return '';

return mask.map((char) => {
return mask.map((char: any) => {
return (char instanceof RegExp) ? placeholderChar : char
}).join('')
}

@@ -141,12 +141,13 @@

export function validate_placa(placa) {
const placaClean = placa.replace(/-/g, '').toUpperCase();
export function validate_placa(placa: string | number) {
let placaClean: string = placa.toString();
placaClean = placaClean.replace(/-/g, '').toUpperCase();
const exp = /[A-Za-z]{3}\-\d{4}/;
const expClean = /[A-Za-z]{3}\d{4}/;
// const letters = placa.substr(0, 3).toUpperCase();
if (!exp.test(placa) && !expClean.test(placaClean)) {
const placaString = placa.toString();
if (!exp.test(placaString) && !expClean.test(placaClean)) {
return false;
}
const found = placa >= PLACAS_INVALID.start && placa <= PLACAS_INVALID.end;
const found = placaString >= PLACAS_INVALID.start && placaString <= PLACAS_INVALID.end;
if (found) {

@@ -153,0 +154,0 @@ return false;

@@ -5,7 +5,7 @@ export function isPresent(obj: any): boolean {

export function isArray(value) {
export function isArray(value: any) {
return (Array.isArray && Array.isArray(value)) || value instanceof Array
}
export function isString(value) {
export function isString(value: any) {
return typeof value === 'string' || value instanceof String

@@ -18,3 +18,3 @@ }

export function isNil(value) {
export function isNil(value: any) {
return typeof value === 'undefined' || value === null

@@ -24,6 +24,6 @@ }

const strCaretTrap = '[]'
export function processCaretTraps(mask) {
export function processCaretTraps(mask: any) {
const indexes = []
let indexOfCaretTrap
let indexOfCaretTrap: number
while (indexOfCaretTrap = mask.indexOf(strCaretTrap), indexOfCaretTrap !== -1) { // eslint-disable-line

@@ -38,3 +38,3 @@ indexes.push(indexOfCaretTrap)

export const modulo11 = (string, size, mod) => {
export const modulo11 = (string: { substring: (arg0: number, arg1: number) => string; }, size: number, mod: number) => {
let soma = 0;

@@ -62,10 +62,12 @@ for (let i = 1; i <= size; i++) {

*/
export function allNumbersAreSame(input) {
input = getAllDigits(input);
const reg = new RegExp('^(\\d)(?!\\1+$)\\d{' + (input.length - 1) + '}$');
return reg.test(input);
export function allNumbersAreSame(inputValue: string) {
const input: string | void = getAllDigits(inputValue);
if (typeof input === 'string') {
const reg = new RegExp('^(\\d)(?!\\1+$)\\d{' + ((<string>input).length - 1) + '}$');
return reg.test(input);
}
}
export function getAllDigits(input) {
export function getAllDigits(input: { match: (arg0: RegExp) => { join: (arg0: string) => void; }; }) {
return input.match(/\d/g).join("");
}

@@ -7,3 +7,3 @@ import { modulo11 } from "./utils";

*/
export function validate_cnpj(cnpj) {
export function validate_cnpj(cnpj: any) {
cnpj = cnpj.replace(/[^\d]+/g, '');

@@ -23,3 +23,3 @@ let tamanho = cnpj.length - 2

export function create_cnpj(cnpj) {
export function create_cnpj(cnpj: string) {
cnpj = cnpj.replace(/[^\d]+/g, '');

@@ -50,5 +50,5 @@

// Valida DVs
let tamanho = cnpj.length - 2
let numeros = cnpj.substring(0, tamanho);
let soma = 0;
let tamanho: number = cnpj.length - 2
let numeros: any = cnpj.substring(0, tamanho);
let soma: any = 0;
let pos = tamanho - 7;

@@ -80,3 +80,3 @@ for (let i = tamanho; i >= 1; i--) {

// http://www.receita.fazenda.gov.br/aplicacoes/atcta/cpf/funcoes.js
export function validate_cpf(strCPF) {
export function validate_cpf(strCPF: any) {
strCPF = strCPF.replace(/[^\d]+/g, '');

@@ -98,3 +98,3 @@ if (strCPF.length !== 11) {

export function create_cpf(strCPF) {
export function create_cpf(strCPF: string) {
strCPF = strCPF.replace(/[^\d]+/g, '');

@@ -144,3 +144,3 @@ if (strCPF === '00000000000') {

export function valida_cep(cep) {
export function valida_cep(cep: string) {
const cepClean = cep.replace(/[^\d]+/g, '');

@@ -154,8 +154,8 @@ const exp = /\d{2}\.\d{3}\-\d{3}/;

export function cep_ranges(cep) {
cep = cep.replace(/[^\d]+/g, '');
export function cep_ranges(cep: string | number) {
cep = (cep.toString()).replace(/[^\d]+/g, '');
cep = parseInt(cep, 10);
const cepString: string = cep.toString();
const found = Object.keys(CEPRange).find(estado => {
const r = new RegExp(CEPRange[estado]).test(cep);
const r = new RegExp(CEPRange[estado]).test(cepString);
if (r) {

@@ -172,3 +172,3 @@ return true;

export function validate_telefone(tel) {
export function validate_telefone(tel: any) {
const telClean = tel.replace(/[^\d]+/g, '');

@@ -186,3 +186,3 @@ tel = tel.replace(/_/g, '');

export function validate_celular(cel) {
export function validate_celular(cel: any) {
let celClean = cel.replace(/[^\d]+/g, '');

@@ -199,3 +199,3 @@ celClean = celClean.replace(/_/g, '');

export function validate_rg(rg) {
export function validate_rg(rg: string) {
let rgClean = rg.replace(/\./g, '');

@@ -213,13 +213,14 @@ rgClean = rgClean.replace(/-/g, '');

export function validate_time(time) {
export function validate_time(time: string | number) {
const expression = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/;
return expression.test(time.value);
const value = time.toString();
return expression.test(value);
}
export function validate_currency(currency) {
export function validate_currency(currency: string | number) {
const regex = /^\d+(?:\.\d{0,2})$/;
return regex.test(currency);
return regex.test(currency.toString());
}
export function validate_number(number) {
export function validate_number(number: string) {
const regex = /^\d+(?:\.\d{0,2})$/;

@@ -229,3 +230,3 @@ return regex.test(number);

export function validate_percentage(percentage) {
export function validate_percentage(percentage: string) {
const regex = /^\d+(?:\.\d{0,2})$/;

@@ -236,3 +237,3 @@ return regex.test(percentage);

export function validate_titulo(titulo) {
export function validate_titulo(titulo: any) {
const tituloClean = titulo.replace(/\./g, '');

@@ -247,3 +248,3 @@ const exp = /\d{4}\.\d{4}\.\d{4}/;

function validaTituloVerificador(titulo) {
function validaTituloVerificador(titulo: string) {
const { dig1, dig2 } = create_titulo(titulo);

@@ -259,3 +260,3 @@ const tam = titulo.length;

export function create_titulo(titulo) {
export function create_titulo(titulo: string) {
const tit = titulo;

@@ -305,3 +306,3 @@ let dig1 = 0;

export function validate_processo(processo) {
export function validate_processo(processo: any) {
let processoClean = processo.replace(/\./g, '');

@@ -318,3 +319,3 @@ processoClean = processoClean.replace(/\-/g, '');

export function validate_renavam(renavam) {
export function validate_renavam(renavam: any) {
let renavamClean = renavam.replace(/\./g, '');

@@ -332,3 +333,3 @@ renavamClean = renavamClean.replace(/\-/g, '');

export function create_renavam(renavam) {
export function create_renavam(renavam: string) {
let dig1 = 0;

@@ -335,0 +336,0 @@ while (renavam.length < 11) {

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