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

br-validator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

br-validator

GainTime Br-validator é uma ferramenta para validação e máscara de CPF, CNPJ, telefones brasileiros, data e máscara de CEP com JavaScript puro..

  • 4.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Como começar

ESM

npm install br-validator
import Br from 'br-validator'

// options é opcional, se vc não passar nada, será:
const options = {
    css: true // Utilizar nosso stylesheet,
    messages: true // Utilizar nossas mensagens de erro
}

const br = new Br(options)
const BR = br.init()

text/javascript

npm install br-validator@4.1.0-script

Será criada uma variável global chamada br

<script type="text/javascript" src="br-validator/dist/index.js"></script>
<script>
  br.init() // Configuração padrão

  // ou
  new br.Br(options).init() // Assim você pode personalizar
</script>

Como utilizar

Adicione o atributo data-validate aos inputs que deseja validar, tal que o valor do atributo pode ser cpf, cnpj, date, brPhone, cep, text ou num.

<input type="text" data-validate="cpf" />

Para validar ceps, utilizamos um formato diferente:

<script>
  const BR = br.init()

  BR.fields.cep.forEach((e) => {
    e.addEventListener('blur', function (f) {
      console.log(f)
      br.cep(f.target, (response) => {
        console.log(response)
      })
    })
  })
</script>

Keywords

FAQs

Package last updated on 23 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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