8000 ensure that all supported e-mail validation modes can be configured · symfony/symfony@b8b3c37 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8b3c37

Browse files
committed
ensure that all supported e-mail validation modes can be configured
1 parent 6b4f603 commit b8b3c37

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use Symfony\Component\Serializer\Serializer;
4646
use Symfony\Component\Translation\Translator;
4747
use Symfony\Component\Uid\Factory\UuidFactory;
48+
use Symfony\Component\Validator\Constraints\Email;
4849
use Symfony\Component\Validator\Validation;
4950
use Symfony\Component\Webhook\Controller\WebhookController;
5051
use Symfony\Component\WebLink\HttpHeaderSerializer;
@@ -1066,7 +1067,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
10661067
->validate()->castToArray()->end()
10671068
->end()
10681069
->scalarNode('translation_domain')->defaultValue('validators')->end()
1069-
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->end()
1070+
->enumNode('email_validation_mode')->values(Email::VALIDATION_MODES + ['loose'])->end()
10701071
->arrayNode('mapping')
10711072
->addDefaultsIfNotSet()
10721073
->fixXmlConfig('path')

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\Exception\LogicException;
1818
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
1919
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
20+
use Symfony\Component\Validator\Constraints\Email;
2021
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
2122

2223
class PhpFrameworkExtensionTest extends FrameworkExtensionTestCase
@@ -245,4 +246,31 @@ public function testRateLimiterLockFactory()
245246

246247
$container->getDefinition('limiter.without_lock')->getArgument(2);
247248
}
249+
250+
/**
251+
* @dataProvider emailValidationModeProvider
252+
*/
253+
public function testValidatorEmailValidationMode(string $mode)
254+
{
255+
$this->expectNotToPerformAssertions();
256+
257+
$this->createContainerFromClosure(function (ContainerBuilder $container) use ($mode) {
258+
$container->loadFromExtension('framework', [
259+
'annotations' => false,
260+
'http_method_override' => false,
261+
'handle_all_throwables' => true,
262+
'php_errors' => ['log' => true],
263+
'validation' => [
264+
'email_validation_mode' => $mode,
265+
],
266+
]);
267+
});
268+
}
269+
270+
public function emailValidationModeProvider()
271+
{
272+
foreach (Email::VALIDATION_MODES as $mode) {
273+
yield [$mode];
274+
}
275+
}
248276
}

0 commit comments

Comments
 (0)
0