New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.9 to 1.2.0

1

dist/index.js

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

currency: validate_1.validate_currency,
number: validate_1.validate_number,
inscricaoestadual: inscricaoestadual_1.validar,

@@ -18,0 +19,0 @@ percentage: validate_1.validate_percentage,

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

},
number: function () {
var x = Math.random() * 10000;
return parseFloat(x.toFixed(2));
},
percentage: makeGeneric(mask_1.MASKS['percentage']),

@@ -120,0 +124,0 @@ placa: function () {

@@ -61,2 +61,14 @@ "use strict";

},
number: {
text: '0.000,00',
textMask: createNumberMask_1.default({
decimalLimit: 2,
thousandsSeparatorSymbol: '.',
decimalSymbol: ',',
allowDecimal: true,
integerLimit: 15,
prefix: '',
suffix: ''
})
},
percentage: {

@@ -147,2 +159,18 @@ text: '00,00%',

},
number: function (numberValue) {
if (!numberValue) {
return '';
}
if (!numberValue.split) {
numberValue += '';
numberValue = numberValue.replace('.', ',');
}
var vals = numberValue.split(',');
var mask = exports.MASKS.number.textMask(vals[0]);
var decimals = vals.length > 1 ? vals[1] + '' : '00';
if (decimals.length > 2) {
decimals = decimals.substring(0, 2);
}
return conformToMask(numberValue, mask, { guide: false }).conformedValue + ',' + decimals;
},
percentage: function (percentageValue) {

@@ -149,0 +177,0 @@ if (!percentageValue) {

@@ -197,2 +197,7 @@ "use strict";

exports.validate_currency = validate_currency;
function validate_number(number) {
var regex = /^\d+(?:\.\d{0,2})$/;
return regex.test(number);
}
exports.validate_number = validate_number;
function validate_percentage(percentage) {

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

3

index.ts

@@ -6,3 +6,3 @@ 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_currency, validate_percentage, validate_rg, validate_time, validate_titulo, validate_processo, validate_celular, validate_renavam, validate_number
} from './src/validate';

@@ -21,2 +21,3 @@ import { validar } from './src/inscricaoestadual';

currency: validate_currency,
number: validate_number,
inscricaoestadual: validar,

@@ -23,0 +24,0 @@ percentage: validate_percentage,

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

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

@@ -111,3 +111,3 @@ # js-brasil

* Processo da justiça - http://geradorbrasileiro.com/processo.html
* Outros: currency, percentage, time (data/hora) - http://geradorbrasileiro.com/others.html
* Outros: currency, percentage, time (data/hora), number - http://geradorbrasileiro.com/others.html

@@ -114,0 +114,0 @@

@@ -114,2 +114,6 @@ import { ESTADOS_SIGLA } from './estados';

},
number: () => {
const x = Math.random() * 10000;
return parseFloat(x.toFixed(2));
},
percentage: makeGeneric(MASKS['percentage']),

@@ -116,0 +120,0 @@ placa: () => {

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

},
number: {
text: '0.000,00',
textMask: createNumberMask({
decimalLimit: 2,
thousandsSeparatorSymbol: '.',
decimalSymbol: ',',
allowDecimal: true,
integerLimit: 15,
prefix: '',
suffix: ''
})
},
percentage: {

@@ -162,2 +174,24 @@ text: '00,00%',

},
number: (numberValue) => {
if (!numberValue) {
return '';
}
if (!numberValue.split) {
numberValue += '';
numberValue = numberValue.replace('.', ',');
}
const vals = numberValue.split(',');
const mask = MASKS.number.textMask(vals[0]);
let decimals = vals.length > 1 ? vals[1] + '' : '00';
if (decimals.length > 2) {
decimals = decimals.substring(0, 2);
}
return conformToMask(
numberValue,
mask,
{ guide: false }
).conformedValue + ',' + decimals;
},
percentage: (percentageValue) => {

@@ -164,0 +198,0 @@ if (!percentageValue) {

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

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

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

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