validateConfigFileName function

bool validateConfigFileName(
  1. String fileName
)

Validates that the given fileName is alphanumeric (with underscores as spaces) and does not start with a number.

Implementation

bool validateConfigFileName(String fileName) {
  final alphabets = RegExp(r'^[a-zA-Z_]+$');
  final alphaNumeric = RegExp(r'^[a-zA-Z0-9_]+$');
  return alphabets.hasMatch(fileName[0]) &&
      alphaNumeric.hasMatch(fileName.substring(1));
}