Mehak Gupta
Mehak Gupta

Reputation: 73

How to validate email from dummy emails?

I am currently working on a project and need validation for validating dummy emails like mailinator or yopmail. These emails should not go through but I can't get any regex for this particular issue.

I have tried different regex but none them worked.

Upvotes: 1

Views: 657

Answers (2)

Gursewak Singh
Gursewak Singh

Reputation: 1968

I made a list of all the disposable domains. You can use this list to validate disposable email.

Exp:

final disposableEmail = [
 "xxyxi.com",
 "musiccode.me",
]

final splitList = _emailController.text.split("@");
if (disposableEmail.contains(splitList[1].trim())) {
    print('Registration with temporary-email-address not allowed');
    return;
}

Upvotes: 4

Shakila
Shakila

Reputation: 1059

You can use the email validator plugin from the pub.dev to validate email easily https://pub.dev/packages/email_validator

example code

void main() {

    var email = "[email protected]";

    assert(EmailValidator.validate(email));
}

Upvotes: 0

Related Questions