-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathE-mail Validator
22 lines (21 loc) · 1.04 KB
/
E-mail Validator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Validator for e-mail id
{[ checks for '@' and '.' present in mail id as they are present in normail mail id "example: ' yashj0304@gmail.com ' " ]}
validator: (value) {
final emailRegex = RegExp(
r'^[\w-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,})$',
);
if (value!.isEmpty) {
Get.snackbar(
'Error',
'Please enter your email address',
);
return '';
} else if (!emailRegex.hasMatch(value)) {
Get.snackbar(
'Error',
'Please enter a valid email address',
);
return '';
}
return null;
},