Code Monkey home page Code Monkey logo

cpf's Introduction

@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"}

cpf's People

Contributors

betafcc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.