isValid static method
bool
isValid(
- String? cpf, [
- dynamic stripBeforeValidation = true
])
Implementation
static bool isValid(String? cpf, [stripBeforeValidation = true]) {
if (stripBeforeValidation) {
cpf = strip(cpf);
}
// CPF must be defined
if (cpf == null || cpf.isEmpty) {
return false;
}
// CPF must have 11 chars
if (cpf.length != 11) {
return false;
}
// CPF can't be blacklisted
if (BLACKLIST.indexOf(cpf) != -1) {
return false;
}
String numbers = cpf.substring(0, 9);
numbers += _verifierDigit(numbers).toString();
numbers += _verifierDigit(numbers).toString();
return numbers.substring(numbers.length - 2) ==
cpf.substring(cpf.length - 2);
}