date static method

String? date(
  1. String? value, {
  2. String? message,
})

Validates date format

Example:

Validators.date('2024-01-15');

Implementation

static String? date(String? value, {String? message}) {
  if (value == null || value.isEmpty) return null;
  try {
    DateTime.parse(value);
    return null;
  } catch (_) {
    return message ?? 'Please enter a valid date';
  }
}