File tree Expand file tree Collapse file tree 3 files changed +31
-16
lines changed Expand file tree Collapse file tree 3 files changed +31
-16
lines changed Original file line number Diff line number Diff line change 1
1
# validar-cpf
2
2
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.
4
6
5
7
[ ![ Actions Status] ( https://github.com/guilhermehn/validar-cpf/workflows/Node%20CI/badge.svg )] ( https://github.com/guilhermehn/validar-cpf/actions )
6
8
[ ![ npm version] ( https://badge.fury.io/js/validar-cpf.svg )] ( http://badge.fury.io/js/validar-cpf )
7
9
[ ![ Known Vulnerabilities] ( https://snyk.io/test/github/guilhermehn/validar-cpf/badge.svg )] ( https://snyk.io/test/github/guilhermehn/validar-cpf )
8
10
9
- ## Instalar
11
+ ## Install
10
12
11
- ` npm install validar-cpf -S `
13
+ ` npm install --save validar-cpf `
12
14
13
- ## Uso
15
+ ## Usage
14
16
15
17
``` 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
+ }
18
23
```
19
24
20
- ## Tamanhos
25
+ ## Package size
21
26
22
27
[ ![ Install size] ( https://badgen.net/packagephobia/install/validar-cpf )] ( https://badgen.net/packagephobia/install/validar-cpf )
23
28
[ ![ Minified size] ( https://badgen.net/bundlephobia/min/validar-cpf )] ( https://badgen.net/bundlephobia/min/validar-cpf )
24
29
[ ![ Minified + gzip size] ( https://badgen.net/bundlephobia/minzip/validar-cpf )] ( https://badgen.net/bundlephobia/minzip/validar-cpf )
25
30
26
- ## Licensa
31
+ ## License
27
32
28
33
MIT
Original file line number Diff line number Diff line change 1
1
export = validarCpf ;
2
2
/**
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.
6
8
* @example
7
9
* const validarCpf = require('validar-cpf');
8
- * console.log(validarCpf('12345678900'));
10
+ *
11
+ * if (validateCpf('123.456.789-87')) {
12
+ * console.log('Valid CPF');
13
+ * }
9
14
*/
10
15
declare function validarCpf ( input : string ) : boolean ;
Original file line number Diff line number Diff line change 4
4
const isRepeatingNumber = ( str ) => / ^ ( \d ) ( \1) { 10 } $ / . test ( str ) ;
5
5
6
6
/**
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.
10
12
* @example
11
13
* const validarCpf = require('validar-cpf');
12
- * console.log(validarCpf('12345678900'));
14
+ *
15
+ * if (validateCpf('123.456.789-87')) {
16
+ * console.log('Valid CPF');
17
+ * }
13
18
*/
14
19
module . exports = function validarCpf ( input ) {
15
20
const cpf = input . replace ( / \D / g, '' ) ;
You can’t perform that action at this time.
0 commit comments