# cpf-validator-x

> Library to validate CPF, Brazilian document

Latest version **1.0.13** (published 2019-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install cpf-validator-x
pnpm add cpf-validator-x
yarn add cpf-validator-x
bun add cpf-validator-x
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2019-12-14 |
| First published | 2019-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Rafael Campos Gonçalves |
| Maintainers | r.goncalves |
| Keywords | validar cpf, validação de cpf, validacao, cpf, validação cpf, cpf validator, cpf validation, validation, validator |

## Links

- npm: https://www.npmjs.com/package/cpf-validator-x
- Repository: https://github.com/Rafaelcamposgoncalves/cpf-validator-x
- Homepage: https://github.com/Rafaelcamposgoncalves/cpf-validator-x#readme
- Issues: https://github.com/Rafaelcamposgoncalves/cpf-validator-x/issues
- npm.io page: https://npm.io/package/cpf-validator-x

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.13 (latest) — 2019-12-14
- 1.0.12 — 2019-12-12
- 1.0.11 — 2019-12-11
- 1.0.10 — 2019-12-11
- 1.0.9 — 2019-12-11
- 1.0.8 — 2019-12-11
- 1.0.7 — 2019-12-11
- 1.0.6 — 2019-12-11
- 1.0.5 — 2019-12-10
- 1.0.4 — 2019-12-10
- 1.0.3 — 2019-12-10
- 1.0.2 — 2019-12-10
- 1.0.1 — 2019-12-10
- 1.0.0 — 2019-12-10

## README

# cpf-validator-x  
  
Library to validate CPF, Brazilian document


### Importing  
```javascript
const cpfValidatorX = require('cpf-validator-x');
```  
  
### Parameters  
(cpf, error message)

| PARAMETER     | VALUE      | OBS                                                        |
|---------------|------------|------------------------------------------------------------|
| cpf           | cpf number | In case of error returns the CPF number                    |
| error message | message    | In case of error returns the message passed this parameter |
  

### Usage examples  
  
#### In the first parameter 3 data types are accepted:  
```javascript
cpfValidatorX.isCpf(33333333333);
```

or:
```javascript
cpfValidatorX.isCpf('33333333333');
```

or:
```javascript
cpfValidatorX.isCpf('333.333.333-33');
```

#### Example with 2 parameters

```javascript
cpfValidatorX.isCpf('33333333333', 'Invalid CPF');
```

> **Note:**
>
> If the second parameter is omitted, no error message will be returned.  
  
### Return  
Returns a **JSON** object with up to 3 values, depending on error and number of parameters passed, Ex:  
  
#### With 1 parameter, and correct CPF:  
```javascript
cpfValidatorX.isCpf(33333333333);
```
>return: {res: true}
  
#### With 1 parameter, and incorrect CPF:  
```javascript
cpfValidatorX.isCpf(33333333333);
```
>return: {res: false, cpf: 33333333333}
  
#### With 2 parameters, and correct CPF:  
```javascript
cpfValidatorX.isCpf(33333333333, "Error: cpf doesn't exist");
```
>return: {res: true}
  
#### With 2 parameters, and incorrect CPF:  
```javascript
cpfValidatorX.isCpf(33333333333, "Error: cpf doesn't exist");
```
>return: {res: false, cpf: 33333333333, error: Error: cpf doesn't exist}

---
_Source: https://npm.io/package/cpf-validator-x · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
