Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
4 changes: 4 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function __construct(
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
}

if (null !== $mode && !\in_array($mode, self::$validationModes, true)) {
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
}

parent::__construct($options, $groups, $payload);

$this->message = $message ?? $this->message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public function testUnknownModesTriggerException()
new Email(['mode' => 'Unknown Mode']);
}

public function testUnknownModeArgumentsTriggerException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The "mode" parameter value is not valid.');
new Email(null, null, 'Unknown Mode');
}

public function testNormalizerCanBeSet()
{
$email = new Email(['normalizer' => 'trim']);
Expand Down