check static method

bool check(
  1. String codiceFiscale
)

Implementation

static bool check(String codiceFiscale) {
  String cf = codiceFiscale.toUpperCase();
  if (cf.length != 16) {
    return false;
  }
  if (!RegExp(r'^[A-Z]{6}[0-9LMNPQRSTUV]{2}[ABCDEHLMPRST]{1}[0-9LMNPQRSTUV]{2}[A-Z]{1}[0-9LMNPQRSTUV]{3}[A-Z]{1}$')
      .hasMatch(cf)) {
    return false;
  }
  final expectedCheckCode = codiceFiscale[15];
  cf = codiceFiscale.substring(0, 15);
  return _getCheckCode(cf).toUpperCase() == expectedCheckCode.toUpperCase();
}