Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ramonpaolo/validation-documents
Package npm to validate and create a CPF and CNPJ
https://github.com/ramonpaolo/validation-documents
good-first-issue javascript nodejs npm opensource typescript typesript validation
Last synced: 14 days ago
JSON representation
Package npm to validate and create a CPF and CNPJ
- Host: GitHub
- URL: https://github.com/ramonpaolo/validation-documents
- Owner: ramonpaolo
- License: mit
- Created: 2022-12-17T14:15:04.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-20T07:11:13.000Z (over 1 year ago)
- Last Synced: 2024-10-05T11:21:57.682Z (about 1 month ago)
- Topics: good-first-issue, javascript, nodejs, npm, opensource, typescript, typesript, validation
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/validate-documents?activeTab=readme
- Size: 262 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validate Documents
[![Run Tests](https://github.com/ramonpaolo/validation-documents/actions/workflows/ci.yml/badge.svg)](https://github.com/ramonpaolo/validation-documents/actions/workflows/ci.yml)
![Code Size](https://img.shields.io/github/languages/code-size/ramonpaolo/validation-documents?style=flat-square)
![Downloads](https://img.shields.io/npm/dm/validate-documents?style=flat-square)
![LICENSE](https://img.shields.io/npm/l/validate-documents?style=flat-square)---
## Index
- [What is it?](#what-is-it)
- [What technologies this project use?](#what-technologies-this-project-use)
- [How install it?](#how-install-it)
- [Example of use](#example-of-use)---
## What is it?
This project, is a lib to validate oficial documents in Brazil. This validate CPF and CNPJ.---
## What technologies this project use?
- Node.Js
- TypeScript
- Jest---
## How install it?
It's simple, just run the command in the terminal, example:
```bash
# Installing package# Yarn
$ yarn add validate-documents# npm
$ npm install validate-documents
```---
## Exemple of use:
### Validate Documents
```javascript
import { validateCpf } from 'validate-documents'const isValidCpf = validateCpf('72994324040')
if(isValidCpf) {
// Follow the flow with valid CPF, how create user
}else{
// Follow the flow with invalid CPF, how return response with error and status code 400
}
```### Create Fake Document Number
```javascript
import { createFakeCpf } from 'validate-documents'try {
const cpfCreated = createFakeCpf()
console.log('created CPF:', cpfCreated)
} catch (error) {
console.error({
error_name: error.name, // Error
error_message: error.message, // Max retry to create fake cpf was hit
})
}
```###### Made with Love by Ramon Paolo Maram :3