added textvalidators
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
String? timeValidator(String? value) {
|
||||
if (value == null || value.isEmpty) return null;
|
||||
|
||||
if (RegExp(r'^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$').hasMatch(value)) {
|
||||
return null;
|
||||
}
|
||||
return 'Not a valid time format';
|
||||
}
|
||||
|
||||
String? dateTimeValidator(String? value) {
|
||||
if (value == null || value.isEmpty) return null;
|
||||
|
||||
return DateTime.tryParse(value) != null ? null : 'Not a date format';
|
||||
}
|
||||
Reference in New Issue
Block a user