A Pen by Sosami Oluwafemi on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Validates a CPF number | |
* @param String: cpfString // User CPF (just numbers or formated(000.000.000-00)) | |
* @return Boolean: success/false // Returns if is valid | |
* Reference and logic: https://www.devmedia.com.br/validar-cpf-com-javascript/23916 | |
* Official code: http://www.receita.fazenda.gov.br/aplicacoes/atcta/cpf/funcoes.js | |
*/ | |
function validateCpf(cpfString: string): boolean { | |
let validated = false; // Start with false |