feature #28842 [Validator] Deprecate checkMX and checkHost on Email validator (fabpot)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Validator] Deprecate checkMX and checkHost on Email validator
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | yes
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | fixes #27559 fixes #28665
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
Commits
-------
c6009a0144
[Validator] deprecate checkMX and checkHost on Email validator
This commit is contained in:
commit
9bec1fcf08
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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(
|
||||
@ -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;
|
||||
@ -64,6 +80,14 @@ class Email extends Constraint
|
||||
@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.');
|
||||
}
|
||||
|
@ -317,6 +317,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
|
||||
/**
|
||||
* @dataProvider getDnsChecks
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
* @group legacy
|
||||
*/
|
||||
public function testDnsChecks($type, $violation)
|
||||
{
|
||||
@ -353,6 +354,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
* @group legacy
|
||||
*/
|
||||
public function testHostnameIsProperlyParsed()
|
||||
{
|
||||
@ -368,6 +370,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provideCheckTypes
|
||||
* @group legacy
|
||||
*/
|
||||
public function testEmptyHostIsNotValid($checkType, $violation)
|
||||
{
|
||||
|
Reference in New Issue
Block a user