cpf-validator-x
Library to validate CPF, Brazilian document
Importing
const cpfValidatorX = ;
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:
cpfValidatorX;
or:
cpfValidatorX;
or:
cpfValidatorX;
Example with 2 parameters
cpfValidatorX;
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;
return: {res: true}
With 1 parameter, and incorrect CPF:
cpfValidatorX;
return: {res: false, cpf: 33333333333}
With 2 parameters, and correct CPF:
cpfValidatorX;
return: {res: true}
With 2 parameters, and incorrect CPF:
cpfValidatorX;
return: {res: false, cpf: 33333333333, error: Error: cpf doesn't exist}