fromNumeroDocumento static method

TipoDocumentoSERPRO? fromNumeroDocumento(
  1. String numero
)

Cria automaticamente a partir do nĂºmero do documento

Implementation

static TipoDocumentoSERPRO? fromNumeroDocumento(String numero) {
  final cleanNumber = numero.replaceAll(RegExp(r'[^\d]'), '');
  if (cleanNumber.length == 11) {
    return TipoDocumentoSERPRO.cpf;
  } else if (cleanNumber.length == 14) {
    return TipoDocumentoSERPRO.cnpj;
  }
  return null;
}