isValid method

bool isValid(
  1. String? pan
)

function to check if the PAN has valid format or not.

returns true if the PAN has valid format.

Implementation

bool isValid(String? pan) {
  if (pan == null || pan.length != 10) {
    // PAN length is not 10
    return false;
  }

  RegExp panRegEx = RegExp(r'[A-Za-z]{5}[0-9]{4}[A-Za-z]{1}');
  return panRegEx.hasMatch(pan);
}