isValidateEmail method
Checks whether the given string is a valid email address.
This method trims the input, converts it to lowercase, and then matches it against a standard email regex pattern.
Returns true
if the string is a valid email, otherwise false
.
Example:
String email = "user@example.com";
bool isValid = email.isValidateEmail(); // true
String invalidEmail = "user@@example..com";
bool isInvalid = invalidEmail.isValidateEmail(); // false
Implementation
bool isValidateEmail() {
if (isEmptyOrNull) return false;
return hasMatch(this.toLowerCase().trim(), RegExpPatterns.email);
}