1.0.13 • Published 4 years ago

cpf-validator-x v1.0.13

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

cpf-validator-x

Library to validate CPF, Brazilian document

Importing

const cpfValidatorX = require('cpf-validator-x');

Parameters

(cpf, error message)

PARAMETERVALUEOBS
cpfcpf numberIn case of error returns the CPF number
error messagemessageIn case of error returns the message passed this parameter

Usage examples

In the first parameter 3 data types are accepted:

cpfValidatorX.isCpf(33333333333);

or:

cpfValidatorX.isCpf('33333333333');

or:

cpfValidatorX.isCpf('333.333.333-33');

Example with 2 parameters

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:

cpfValidatorX.isCpf(33333333333);

return: {res: true}

With 1 parameter, and incorrect CPF:

cpfValidatorX.isCpf(33333333333);

return: {res: false, cpf: 33333333333}

With 2 parameters, and correct CPF:

cpfValidatorX.isCpf(33333333333, "Error: cpf doesn't exist");

return: {res: true}

With 2 parameters, and incorrect CPF:

cpfValidatorX.isCpf(33333333333, "Error: cpf doesn't exist");

return: {res: false, cpf: 33333333333, error: Error: cpf doesn't exist}

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago