validateFEIN static method

String? validateFEIN(
  1. String? value
)

Ensures that FEIN will be of form 9xx-xxx-xxxx (stripping out the "-")

Implementation

static String? validateFEIN(String? value) {
  if (value == null) {
    return 'Value cannot be empty';
  }

  // Ensure it starts with 9
  if (!value.startsWith("9")) {
    return 'Value must begin with a 9 to be considered a valid FEIN';
  }

  // Make sure its correct length (strip out unnecessary chars)
  var stripped = value.replaceAll("-", "");
  if (stripped.length != 10) {
    return 'FEIN should be 10 integers long';
  }

  return null;
}