emptyFieldValidator static method

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

emptyFieldValidator to validate if a form field is empty or not

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

Implementation

static String? emptyFieldValidator(String? value, [String? errorMessage]) {
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  }

  return null;
}