Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c944281

Browse filesBrowse files
committed
bug #47189 [Validator] Add additional hint when egulias/email-validator needs to be installed (mpdude)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] Add additional hint when `egulias/email-validator` needs to be installed | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | When using the `Symfony\Component\Validator\Constraints\Email` constraint with `'mode' => 'strict'`, a helpful error message is shown when the necessary package is not installed. However, when configuring `strict` mode as a framework setting (https://symfony.com/doc/current/reference/configuration/framework.html#email-validation-mode) and omitting the `mode` setting on the constraint itself, that message was missing. Commits ------- 3924498 [Validator] Hint that `egulias/email-validator` needs to be installed for strict mode as default config
2 parents 675756f + 3924498 commit c944281
Copy full SHA for c944281

File tree

1 file changed

+4
-0
lines changed
Filter options

1 file changed

+4
-0
lines changed

‎src/Symfony/Component/Validator/Constraints/EmailValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/EmailValidator.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public function validate($value, Constraint $constraint)
100100
}
101101

102102
if (null === $constraint->mode) {
103+
if (Email::VALIDATION_MODE_STRICT === $this->defaultMode && !class_exists(EguliasEmailValidator::class)) {
104+
throw new LogicException(sprintf('The "egulias/email-validator" component is required to make the "%s" constraint default to strict mode.', EguliasEmailValidator::class));
105+
}
106+
103107
$constraint->mode = $this->defaultMode;
104108
}
105109

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.