isValid static method

bool isValid(
  1. String rawInput, {
  2. required String countryCode,
})

Implementation

static bool isValid(String rawInput, {required String countryCode}) {
  final String code = dialCodeOf(countryCode);
  final String national = nationalNumber(rawInput, countryCode: code);
  if (national.length < nationalMinDigits || national.length > maxNationalDigits(code)) return false;
  if (national.startsWith("0") && !significantLeadingZeroDialCodes.contains(code)) return false;
  final List<int>? lengths = nationalDigitLengths[code];
  return lengths == null || lengths.contains(national.length);
}