validateGasConsumerNumber function

bool validateGasConsumerNumber(
  1. String input,
  2. String company
)

Validates a gas bill consumer number: 11 digits for SNGPL, 10 digits for SSGC, as their bill pages ask for (retrieved 2026-11-18; see DATA.md in the repository). No check digit is published, so only the format is checked.

company is 'SNGPL' or 'SSGC' in any case, e.g. GasCompany.sngpl.value; anything else returns false. Never throws.

validateGasConsumerNumber('12345678901', 'SNGPL'); // true
validateGasConsumerNumber('1234567890', GasCompany.ssgc.value); // true

Implementation

bool validateGasConsumerNumber(String input, String company) {
  final name = jsToUpperCase(company);
  int? digits;
  for (final c in GasCompany.values) {
    if (c.value == name) digits = c._digits;
  }
  if (digits == null) return false;
  final text = toAsciiDigits(input).replaceAll(_separators, '');
  return text.length == digits && _allDigits.hasMatch(text);
}