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

us-formly-templates

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

us-formly-templates - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

13

package.json
{
"name": "us-formly-templates",
"version": "1.0.0",
"version": "1.0.1",
"description": "Extensão com templates para usar formly com bootstrap",
"main": "index.js",
"scripts": {

@@ -22,2 +21,12 @@ "test": "echo \"Error: no test specified\" && exit 1"

"author": "Undefined Source",
"contributors": [
{
"name": "Julio Cezar Fabiane",
"email": "juliofabiane1@gmail.com"
},
{
"name": "Jhon Mike Soares",
"email": "developer@jhonmike.com.br"
}
],
"license": "MIT",

@@ -24,0 +33,0 @@ "bugs": {

# us-formly-templates
Extensão de templates para utilizar formly com bootstrap

@@ -1,3 +0,5 @@

angular.module('usFormlyTemplates', ['formly', 'formlyBootstrap'])
angular.module('usFormlyTemplates', [
'formly',
'formlyBootstrap'
])
.run(function(formlyConfig, formlyValidationMessages) {

@@ -8,3 +10,2 @@ formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = 'fc.$touched || form.$submitted';

})
.config(['formlyConfigProvider',

@@ -16,3 +17,3 @@ function(formlyConfigProvider) {

name: 'validation',
types: ['input'],
types: ['input', 'maskedInput', 'cpf', 'rg', 'cnpj'],
template: `

@@ -45,2 +46,152 @@ <formly-transclude></formly-transclude>

//CPF
formlyConfigProvider.setType({
name: 'cpf',
extends: 'maskedInput',
defaultOptions: {
validators: {
cpf: {
expression: function(viewValue, modelValue) {
var cpf = modelValue || viewValue;
if(cpf){
if (cpf.length != 11 ||
cpf == "00000000000" ||
cpf == "11111111111" ||
cpf == "22222222222" ||
cpf == "33333333333" ||
cpf == "44444444444" ||
cpf == "55555555555" ||
cpf == "66666666666" ||
cpf == "77777777777" ||
cpf == "88888888888" ||
cpf == "99999999999")
return false;
var add = 0;
for (var i = 0; i < 9; i++)
add += parseInt(cpf.charAt(i)) * (10 - i);
var rev = 11 - (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(9)))
return false;
add = 0;
for (i = 0; i < 10; i++)
add += parseInt(cpf.charAt(i)) * (11 - i);
rev = 11 - (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(10)))
return false;
return true;
}
return false;
},
message: '"CPF inválido"'
}
},
templateOptions: {
mask: '999.999.999-99'
}
}
});
//RG
formlyConfigProvider.setType({
name: 'rg',
extends: 'maskedInput',
defaultOptions: {
templateOptions: {
mask: '99.999.999-9',
}
}
});
//CNPJ
formlyConfigProvider.setType({
name: 'cnpj',
extends: 'maskedInput',
defaultOptions: {
validators: {
cnpj: {
expression: function(viewValue, modelValue) {
var cnpj = modelValue || viewValue;
if(cnpj){
if (cnpj == "00000000000000" ||
cnpj == "11111111111111" ||
cnpj == "22222222222222" ||
cnpj == "33333333333333" ||
cnpj == "44444444444444" ||
cnpj == "55555555555555" ||
cnpj == "66666666666666" ||
cnpj == "77777777777777" ||
cnpj == "88888888888888" ||
cnpj == "99999999999999")
return false;
var tamanho = cnpj.length - 2
var numeros = cnpj.substring(0,tamanho);
var digitos = cnpj.substring(tamanho);
var soma = 0;
var pos = tamanho - 7;
for (var i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2)
pos = 9;
}
var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(0))
return false;
tamanho = tamanho + 1;
numeros = cnpj.substring(0,tamanho);
soma = 0;
pos = tamanho - 7;
for (var i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2)
pos = 9;
}
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(1))
return false;
return true;
}
return false;
},
message: '"CNPJ inválido"'
}
},
templateOptions: {
mask: '99.999.999/9999-99'
}
}
});
//CEP
formlyConfigProvider.setType({
name: 'cep',
extends: 'maskedInput',
defaultOptions: {
templateOptions: {
mask: '99.999-999'
}
}
});
//Telefone
formlyConfigProvider.setType({
name: 'fone',
extends: 'maskedInput',
defaultOptions: {
templateOptions: {
mask: '(99) 9999-9999?9'
}
}
});
//Switch

@@ -47,0 +198,0 @@ formlyConfigProvider.setType({

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