date static method

String? date(
  1. String? string, {
  2. String? errorMessage,
})

Date validator (YYYY-MM-DD).

Implementation

static String? date(String? string, {String? errorMessage}) {
  final dateRegExp = RegExp(r'^\d{4}-\d{2}-\d{2}$');
  if (string == null || string.isEmpty || dateRegExp.hasMatch(string)) {
    return null;
  }
  return errorMessage ?? FieldBlocValidatorsErrors.date;
}