time static method
⏰ Time Validator (HH:mm)
Implementation
static String? time(
String? value, {
String errorMsg = 'Enter a valid time (HH:mm)',
}) {
if (value == null || value.isEmpty) return 'Time is required';
final regex = RegExp(r'^(?:[01]\d|2[0-3]):[0-5]\d$');
return regex.hasMatch(value) ? null : errorMsg;
}