forked from definitelyme/flutter_paystack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_utils.dart
More file actions
29 lines (26 loc) · 802 Bytes
/
Copy pathstring_utils.dart
File metadata and controls
29 lines (26 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class StringUtils {
static bool isEmpty(String? value) {
return value == null || value.length < 1 || value.toLowerCase() == "null";
}
static bool isValidEmail(String? email) {
if (isEmpty(email)) return false;
RegExp regExp = new RegExp(_emailRegex);
return regExp.hasMatch(email!);
}
/// Method to nullify an empty String.
/// [value] - A string we want to be sure to keep null if empty
/// Returns null if a value is empty or null, otherwise, returns the value
static String? nullify(String? value) {
if (isEmpty(value)) {
return null;
}
return value;
}
}
const _emailRegex = r"[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
"\\@" +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
"(" +
"\\." +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
")+";