Skip to content
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

[Validator] Email Validator does not work properly #13739

Closed
filipgolonka opened this issue Feb 19, 2015 · 5 comments
Closed

[Validator] Email Validator does not work properly #13739

filipgolonka opened this issue Feb 19, 2015 · 5 comments

Comments

@filipgolonka
Copy link

Simple code:

$email = 'email@domain.com@';
$constraints = array(
    new \Symfony\Component\Validator\Constraints\Email(),
    new \Symfony\Component\Validator\Constraints\NotBlank()
);

 $errors = $this->get('validator')->validateValue($email, $constraints);

 assert(count($errors) != 0);

This code is expected not to produce a warning, but it does.

@jakzal
Copy link
Contributor

jakzal commented Feb 19, 2015

Could you paste the warning it produces please?

@filipgolonka
Copy link
Author

PHP Warning:  assert(): Assertion failed in FILE on line LINE

The workaround is to enable strict validation and install egulias/email-validator:

$email = 'email@domain.com@';
$constraints = array(
    new \Symfony\Component\Validator\Constraints\Email(array(
        'strict' => true
    )),
    new \Symfony\Component\Validator\Constraints\NotBlank()
);

 $errors = $this->get('validator')->validateValue($email, $constraints);

 assert(count($errors) != 0);

This code does not produce warning.

@SoboLAN
Copy link

SoboLAN commented Feb 22, 2015

@filipgolonka I tried your code on the latest Symfony 2.6 release (2.6.4 to be more precise) and could not reproduce your issue.

count($errors) in my case is 0.

What Symfony version did you use ?

@filipgolonka
Copy link
Author

2.6.1. I will upgrade symfony in my project to 2.6.4 and will see, what happens. I will let here know, if the problem stil occurs.

@webmozart
Copy link
Contributor

Closing due to lack of feedback.

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

No branches or pull requests

4 participants