8000 [Validator] Deprecate checkMX and checkHost on Email validator by fabpot · Pull Request #28842 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Deprecate checkMX and checkHost on Email validator #28842

< 8000 div class="gh-header-actions mt-0 mb-3 mb-md-2 ml-1 flex-md-order-1 flex-shrink-0 d-flex flex-items-center gap-1">
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

Merged
merged 1 commit into from
Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions UPGRADE-4.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ TwigBundle
Validator
---------

* The `checkMX` and `checkHost` properties of the Email constraint are deprecated
* The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead
* The `ValidatorBuilderInterface` has been deprecated and `ValidatorBuilder` made final
* Deprecated validating instances of `\DateTimeInterface` in `DateTimeValidator`, `DateValidator` and `TimeValidator`. Use `Type` instead or remove the constraint if the underlying model is type hinted to `\DateTimeInterface` already.
Expand Down
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ TwigBundle
Validator
--------

* The `checkMX` and `checkHost` properties of the Email constraint were removed
* The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead.
* Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead.
* Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint.
Expand Down
26 changes: 25 additions & 1 deletion src/Symfony/Component/Validator/Constraints/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ class Email extends Constraint
public const VALIDATION_MODE_LOOSE = 'loose';

const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310';

/**
* @deprecated since Symfony 4.2.
*/
const MX_CHECK_FAILED_ERROR = 'bf447c1c-0266-4e10-9c6c-573df282e413';

/**
* @deprecated since Symfony 4.2.
*/
const HOST_CHECK_FAILED_ERROR = '7da53a8b-56f3-4288-bb3e-ee9ede4ef9a1';

protected static $errorNames = array(
Expand All @@ -49,11 +57,19 @@ class Email extends Constraint
);

public $message = 'This value is not a valid email address.';

/**
* @deprecated since Symfony 4.2.
*/
public $checkMX = false;

/**
* @deprecated since Symfony 4.2.
*/
public $checkHost = false;

/**
* @deprecated since Symfony 4.1. Set mode to "strict" instead.
* @deprecated since Symfony 4.1, set mode to "strict" instead.
*/
public $strict;
public $mode;
Expand All @@ -64,6 +80,14 @@ public function __construct($options = null)
@trigger_error(sprintf('The "strict" property is deprecated since Symfony 4.1. Use "mode"=>"%s" instead.', self::VALIDATION_MODE_STRICT), E_USER_DEPRECATED);
}

if (\is_array($options) && array_key_exists('checkMX', $options)) {
@trigger_error('The "checkMX" property is deprecated since Symfony 4.2.', E_USER_DEPRECATED);
}

if (\is_array($options) && array_key_exists('checkHost', $options)) {
@trigger_error('The "checkHost" property is deprecated since Symfony 4.2.', E_USER_DEPRECATED);
}

if (\is_array($options) && array_key_exists('mode', $options) && !\in_array($options['mode'], self::$validationModes, true)) {
throw new \InvalidArgumentException('The "mode" parameter value is not valid.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ public function getInvalidEmailsForStrictChecks()
/**
* @dataProvider getDnsChecks
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
* @group legacy
*/
public function testDnsChecks($type, $violation)
{
Expand Down Expand Up @@ -353,6 +354,7 @@ public function getDnsChecks()

/**
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
* @group legacy
*/
public function testHostnameIsProperlyParsed()
{
Expand All @@ -368,6 +370,7 @@ public function testHostnameIsProperlyParsed()

/**
* @dataProvider provideCheckTypes
* @group legacy
*/
public function testEmptyHostIsNotValid($checkType, $violation)
{
Expand Down
0