PHP code example of chelout / simple-email-validator

1. Go to this page and download the library: Download chelout/simple-email-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chelout / simple-email-validator example snippets


$validation = new EmailValidator([
    new RegexpRule(),
    new MxRule(),
]);
$validation->validate('[email protected]'); // boolean result
var_dump($validation->getErrors());

class FilterVarRule implements RuleContract
{
    public function isValid(string $email): bool
    {
        return ! (filter_var($email, FILTER_VALIDATE_EMAIL) === false);
    }

    public function getError(): string
    {
        return 'Filter Var Rule failed.';
    }
}