vidValidator static method

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

vidValidator to validate Aadhaar VID number

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

Implementation

static String? vidValidator(String? value, [String? errorMessage]) {
  RegExp regex = CustomRegEx.aadhaarVidRegex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (value.length != 16) {
    return errorMessage ?? 'Please enter a valid VID number';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter a valid VID number';
  }
  return null;
}