Skip to content

[Validator][Email] - Strict validation and soft dependency #9140

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
wants to merge 16 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#1581 - CS
  • Loading branch information
egulias committed Jan 12, 2014
commit 7ce25284ceb0c6d4afc1f309c12bb1377a0a8564
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EmailValidator extends ConstraintValidator
*
* @var Boolean
*/
protected $isStrict;
private $isStrict;

public function __construct($strict)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing phpdoc. and it should set a default as well to not break BC.
and I wonder why this option is needed? why have a strict option on the constraint and on the validator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the following:

  • You can pass the strictnes to the EmailConstraint when writing the validation rules, e.g @Email(strict=true) on a per field basis
  • You can set in the config.yml system wide strict = true. This setting can only be injected into the EmailValidator (as far as I know)

{
Expand All @@ -54,7 +54,7 @@ public function validate($value, Constraint $constraint)
$constraint->strict = $this->isStrict;
}

if ($constraint->strict === true && class_exists('\Egulias\EmailValidator\EmailValidator')) {
if (true === $constraint->strict && class_exists('\Egulias\EmailValidator\EmailValidator')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ($constraint->strict ... is enough

$strictValidator = new StrictEmailValidator();
$valid = $strictValidator->isValid($value, $constraint->checkMX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably disable MX checks here as it's going to be redone below anyway.

} elseif ($constraint->strict === true) {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy