Line data Source code
1 : extension StringValidation on String {
2 : /// Check if the string is a valid email address
3 0 : bool get isEmail {
4 0 : final emailRegex = RegExp(r'^[\w\.-]+@[a-zA-Z\d\.-]+\.[a-zA-Z]{2,}$');
5 0 : return emailRegex.hasMatch(this);
6 : }
7 : }
8 :
9 0 : String? emailValidation(String? value) {
10 0 : if (value == null || value.isEmpty) {
11 : return "Veuillez entrer un email";
12 0 : } else if (!value.isEmail) {
13 : return "Veuillez entrer une addresse email valide";
14 : }
15 : return null;
16 : }
17 :
18 0 : String? passwordValidation(String? value) {
19 0 : if (value == null || value.isEmpty) {
20 : return "Veuillez entrer un mot de passe";
21 : }
22 : // final regex = RegExp(r'''/[^\w,?;.:!%$\^~#_@&<>"'\/\{\[\(\|\-\)\]\}]+/gm''');
23 : // if (regex.hasMatch(value)) {
24 : // return "Veillez entrer un mot de passe valide";
25 : // }
26 : return null;
27 : }
|