bankAccountNumberValidator static method

String? bankAccountNumberValidator(
  1. String? value, [
  2. String? errorMessage
])

bankAccountNumberValidator to validate bank account number

validator: (value) => SimpleValidations.bankAccountNumberValidator(value, [errorMessage]),

Implementation

static String? bankAccountNumberValidator(String? value,
    [String? errorMessage]) {
  RegExp regex = CustomRegEx.accountNumberRegex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter a valid bank account number';
  }
  return null;
}