PHP code example of dossierdata / laravel-email-validator

1. Go to this page and download the library: Download dossierdata/laravel-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/ */

    

dossierdata / laravel-email-validator example snippets




// Rule without parameters will default to only checking RFC
$validator = \Validator::make([
    'email' => '[email protected]'
], [
    'email' => 'validate_email',
]);

if ($validator->fails()) {
    dump($validator->errors());
}

// Rule with parameters
$validator = \Validator::make([
    'email' => '[email protected]'
], [
    'email' => 'validate_email:rfc,spf:127.0.0.1,dns',
]);

if ($validator->fails()) {
    dump($validator->errors());
}



$rules = [
    'rfc',
    'spf:127.0.0.1',
    'dns'
];

$emailValidator = app(\Dossierdata\LaravelEmailValidator\Contracts\EmailValidator::class);

if (!$emailValidator->validateValue('[email protected]', $rules)) {
    dump($emailValidator->errors());
}