Skip to content

email validator says that *@* is valid e-mail address #28596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erikroznbeker opened this issue May 23, 2019 · 6 comments
Closed

email validator says that *@* is valid e-mail address #28596

erikroznbeker opened this issue May 23, 2019 · 6 comments

Comments

@erikroznbeker
Copy link

  • Laravel Version: 5.8.18
  • PHP Version: 7.2.10
  • Database Driver & Version: pqsql

Description: After update to laravel 5.8 e-mail validation seems broken and things like @ are consider valid e-mail addresses.

Steps To Reproduce:

run this PHP unit test:

/**
     * @test
     */

    public function mailValidation() {
        $rules = [
            'email' => ['email']
        ];
        $args = [
            'email' => '*@*'  // "*@*" is not valid e-mail address
        ];
        $this->assertTrue(Validator::make($args, $rules)->fails());
    }
@bonzai
Copy link
Contributor

bonzai commented May 23, 2019

Laravel makes use of https://github.com/egulias/EmailValidator to do email validation so if you feel that this is a bug please open up an issue on their issue tracker: https://github.com/egulias/EmailValidator/issues

@dwightwatson
Copy link
Contributor

This issue keeps coming up, I don't think the change to email validation represents what most developers would want/expect. I'd love to see it reconsidered, or the strict email validation becoming opt-in.

@arjasco
Copy link
Contributor

arjasco commented May 24, 2019

I opened discussion beginning of March: laravel/ideas#1555

@driesvints
Copy link
Member

Please see the links in the comments above and try to search for your issue before opening up a new one. Thanks!

@felorhik
Copy link

felorhik commented Jun 7, 2019

It looks like this cannot be resolved by opening support tickets in the package used for email validation, It already has options to resolve this so those options would need to be somehow integrated into laravel.

I added a comment in laravel/ideas#1555 listed above about modifications that could be made to the email validation rule to get around this. I don't think this is a bug, just there is a number of cases where an override may be required to achieve the needed level of email validation. The package used by laravel supports that, however that control is not extended through rule options.

@pactode
Copy link
Contributor

pactode commented Jun 16, 2019

Until this can be handled by Laravel, one can extend the validator with a custom rule.

Add the following to the boot method of your AppServiceProvider:

use Illuminate\Support\Facades\Validator;

Validator::extend(
    'email_simple',
    function ($attribute, $value, $parameters, $validator) {
        return filter_var($value, FILTER_VALIDATE_EMAIL);
    }
);

This will allow you to use the email_simple validation rule instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants