Skip to content

Commit 116bba7

Browse files
committed
fix(docs): update docs with more details
1 parent 1e5198f commit 116bba7

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
# validar-cpf
22

3-
> Valida um número de CPF baseado no algorítmo "módulo 11"
3+
Validates Brazilian CPF document number using the "módulo 11" algorithm.
4+
5+
Anything in the input string that is not a number will be removed during the validation, so there is no need to sanitize the input beforehand.
46

57
[![Actions Status](https://github.com/guilhermehn/validar-cpf/workflows/Node%20CI/badge.svg)](https://github.com/guilhermehn/validar-cpf/actions)
68
[![npm version](https://badge.fury.io/js/validar-cpf.svg)](http://badge.fury.io/js/validar-cpf)
79
[![Known Vulnerabilities](https://snyk.io/test/github/guilhermehn/validar-cpf/badge.svg)](https://snyk.io/test/github/guilhermehn/validar-cpf)
810

9-
## Instalar
11+
## Install
1012

11-
`npm install validar-cpf -S`
13+
`npm install --save validar-cpf`
1214

13-
## Uso
15+
## Usage
1416

1517
```js
16-
const validarCpf = require('validar-cpf');
17-
validarCpf('12345678987'); // false
18+
const validateCpf = require('validar-cpf');
19+
20+
if (validateCpf('123.456.789-87')) {
21+
console.log('Valid CPF');
22+
}
1823
```
1924

20-
## Tamanhos
25+
## Package size
2126

2227
[![Install size](https://badgen.net/packagephobia/install/validar-cpf)](https://badgen.net/packagephobia/install/validar-cpf)
2328
[![Minified size](https://badgen.net/bundlephobia/min/validar-cpf)](https://badgen.net/bundlephobia/min/validar-cpf)
2429
[![Minified + gzip size](https://badgen.net/bundlephobia/minzip/validar-cpf)](https://badgen.net/bundlephobia/minzip/validar-cpf)
2530

26-
## Licensa
31+
## License
2732

2833
MIT

index.d.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
export = validarCpf;
22
/**
3-
* Validates Brazilian CPF document number using the "módulo 11" algorithm
4-
* @param {String} input - CPF number to be tested
5-
* @return {Boolean}
3+
* Validates Brazilian CPF document number using the "módulo 11" algorithm.
4+
* Anything in the input string that is not a number will be removed during the validation,
5+
* so there is no need to sanitize the input beforehand.
6+
* @param {String} input - CPF number to be tested.
7+
* @return {Boolean} Boolean indicating whether the input string contains a valid CPF number.
68
* @example
79
* const validarCpf = require('validar-cpf');
8-
* console.log(validarCpf('12345678900'));
10+
*
11+
* if (validateCpf('123.456.789-87')) {
12+
* console.log('Valid CPF');
13+
* }
914
*/
1015
declare function validarCpf(input: string): boolean;

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
const isRepeatingNumber = (str) => /^(\d)(\1){10}$/.test(str);
55

66
/**
7-
* Validates Brazilian CPF document number using the "módulo 11" algorithm
8-
* @param {String} input - CPF number to be tested
9-
* @return {Boolean}
7+
* Validates Brazilian CPF document number using the "módulo 11" algorithm.
8+
* Anything in the input string that is not a number will be removed during the validation,
9+
* so there is no need to sanitize the input beforehand.
10+
* @param {String} input - CPF number to be tested.
11+
* @return {Boolean} Boolean indicating whether the input string contains a valid CPF number.
1012
* @example
1113
* const validarCpf = require('validar-cpf');
12-
* console.log(validarCpf('12345678900'));
14+
*
15+
* if (validateCpf('123.456.789-87')) {
16+
* console.log('Valid CPF');
17+
* }
1318
*/
1419
module.exports = function validarCpf(input) {
1520
const cpf = input.replace(/\D/g, '');

0 commit comments

Comments
 (0)