checkNorwayBBAN function

bool checkNorwayBBAN(
  1. String bban
)

Used for Norway BBAN check

@ignore

Implementation

bool checkNorwayBBAN(String bban) {
  const List<int> weights = <int>[5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
  final String bbanWithoutSpacesAndPeriods =
      bban.replaceAll(RegExp(r'[\s.]+'), '');
  final int controlDigit =
      int.parse(bbanWithoutSpacesAndPeriods[10], radix: 10);
  final String bbanWithoutControlDigit =
      bbanWithoutSpacesAndPeriods.substring(0, 10);
  int sum = 0;
  for (int index = 0; index < 10; index++) {
    sum +=
        int.parse(bbanWithoutControlDigit[index], radix: 10) * weights[index];
  }
  final int remainder = sum % 11;

  return controlDigit == (remainder == 0 ? 0 : 11 - remainder);
}