cpf static method

bool cpf(
  1. String cpf, [
  2. dynamic stripBeforeValidation = true
])

Implementation

static bool cpf(String cpf, [stripBeforeValidation = true]) {
  if (cpf.length >= 11) {
    cpf = cpf.replaceAll(' ', '');
    cpf = cpf.replaceAll('-', '');
  } else {
    return false;
  }

  if (stripBeforeValidation) {
    cpf = stripCpf(cpf);
  }

  if (blackListCpf.contains(cpf)) {
    return false;
  }

  String numbers = cpf.substring(0, 9);
  numbers += _verifierDigitCpf(numbers).toString();
  numbers += _verifierDigitCpf(numbers).toString();

  return numbers.substring(numbers.length - 2) ==
      cpf.substring(cpf.length - 2);
}