Skip to content

[FrameworkBundle] ensure that all supported e-mail validation modes can be configured #60365

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
May 7, 2025
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
ensure that all supported e-mail validation modes can be configured
  • Loading branch information
xabbuh committed May 6, 2025
commit b8b3c37f3feda9b5327a7958e93b833d922e8a28
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Uid\Factory\UuidFactory;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Webhook\Controller\WebhookController;
use Symfony\Component\WebLink\HttpHeaderSerializer;
Expand Down Expand Up @@ -1066,7 +1067,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
->validate()->castToArray()->end()
->end()
->scalarNode('translation_domain')->defaultValue('validators')->end()
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->end()
->enumNode('email_validation_mode')->values(Email::VALIDATION_MODES + ['loose'])->end()
Copy link
Member

@Kocal Kocal May 7, 2025

Choose a reason for hiding this comment

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

I think we must check if class Email exists before using it, it broke our dev-tests suite on Symfony UX https://github.com/symfony/ux/actions/runs/14882498252/job/41793658394?pr=2714

Copy link
Member

Choose a reason for hiding this comment

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

Opened #60373

->arrayNode('mapping')
->addDefaultsIfNotSet()
->fixXmlConfig('path')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;

class PhpFrameworkExtensionTest extends FrameworkExtensionTestCase
Expand Down Expand Up @@ -245,4 +246,31 @@ public function testRateLimiterLockFactory()

$container->getDefinition('limiter.without_lock')->getArgument(2);
}

/**
* @dataProvider emailValidationModeProvider
*/
public function testValidatorEmailValidationMode(string $mode)
{
$this->expectNotToPerformAssertions();

$this->createContainerFromClosure(function (ContainerBuilder $container) use ($mode) {
$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'validation' => [
'email_validation_mode' => $mode,
],
]);
});
}

public function emailValidationModeProvider()
{
foreach (Email::VALIDATION_MODES as $mode) {
yield [$mode];
}
}
}
Loading
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