You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
class Validators { static String? validateName({required String? name}) { if (name == null || name.isEmpty) { return 'Name can\'t be empty'; }
return null; }
static String? validateEmail({required String? email}) { RegExp emailRegExp = RegExp( r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$");
if (email == null || email.isEmpty) { return 'Email can\'t be empty'; } else if (!emailRegExp.hasMatch(email)) { return 'Enter a correct email'; }
return null; }
static String? validatePassword({required String? password}) { if (password == null || password.isEmpty) { return 'Password can\'t be empty'; } else if (password.length < 6) { return 'Enter a password with length at least 6'; }
return null; }
static String? validateConfirmPassword( {required String? password, required String? confirmPassword}) { if (password == null || confirmPassword == null || password != confirmPassword) { return 'Enter the same password'; }
return null; } }
|