time static method

Validator time({
  1. String format = 'HH:mm',
  2. String? message,
})

Time validator (expects HH:mm in 24h format by default) Time validator

Implementation

static Validator time({String format = 'HH:mm', String? message}) {
  return (String? value) {
    if (value == null || value.trim().isEmpty) {
      return message ?? FVMessages.invalidTime();
    }
    try {
      DateFormat(format).parseStrict(value.trim()); // throws if invalid
      return null; // ✅ valid
    } catch (_) {
      return message ?? FVMessages.invalidTime();
    }
  };
}