added validators

This commit is contained in:
2026-06-19 14:01:58 +02:00
parent 20a7c88d2f
commit 9e950a1767
+14
View File
@@ -12,3 +12,17 @@ String? dateTimeValidator(String? value) {
return DateTime.tryParse(value) != null ? null : 'Not a date format'; return DateTime.tryParse(value) != null ? null : 'Not a date format';
} }
String? coordinatesValidator(String? value) {
if (value == null || value.isEmpty) return null;
if (RegExp(r'^\d+\.?\d*, *\d+\.?\d*$').hasMatch(value)) {
return null;
}
return 'Not a valid coordinate format';
}
String? notEmptyValidator(String? value) {
if (value != null && value.isNotEmpty) return null;
return 'Can\'t be empty';
}