Socket
Book a DemoInstallSign in
Socket

@betafcc/cpf

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@betafcc/cpf

Micro-utilitário para validação e geração de CPFs

1.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@betafcc/cpf

Micro-utilitário para validação e geração de CPFs

Install

npm i @betafcc/cpf

Usage

import { Cpf } from '@betafcc/cpf'

ou

const { Cpf } = require('@betafcc/cpf')

static from(cpf: string, uf?: Uf): Cpf

Gera um objeto Cpf

Possíveis assinaturas:

Cpf.from('453.178.287-91') // Completo e pontuado
Cpf.from('45317828791') // Completo e não pontuado
Cpf.from('453.178.287') // Sem os dígitos verificadores
Cpf.from('453.178.28', 'RJ') // Específicando a UF pela sigla

static isValid(cpf: unknown): boolean

Retorna true se o argumento é uma string com um cpf válido

Com pontuação:

Cpf.isValid('453.178.287-91') // true

Sem pontuação:

Cpf.isValid('45317828791') // true

Dígito verificador inválido:

Cpf.isValid('45317828792') // false

static random(uf?: Uf): Cpf

Gera um Cpf aleatório

Cpf.random() // Cpf { __cpf: '453.178.287-91' }
Cpf.random('RJ') // Cpf { __cpf: '453.178.287-91' }

format(): CpfString

Cpf.from('45317828791').format() // '453.178.287-91'

strip(): CpfString

Cpf.from('453.178.287-91').strip() // '45317828791'

equals(other: Cpf): boolean

possibleUfs(): Set<Uf>

Retorna as possíveis UFs de origem

see https://janio.sarmento.org/curiosidade-identificacao-de-cpf-conforme-o-estado/

Cpf.from('453.178.287-91').possibleUfs() // Set {"RJ", "ES"}

Keywords

cpf

FAQs

Package last updated on 05 Aug 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.