added validators
This commit is contained in:
1 parent
20a7c88d2f
commit
9e950a1767
1 file changed
+14
@@ -12,3 +12,17 @@ String? dateTimeValidator(String? value) {
|
||||
|
||||
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';
|
||||
}
|
||||
Reference in new issue
Block a user