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 1f7bc10

Browse filesBrowse files
committed
minor #48987 [Validator] Make exception for all constraints consistent (fabpot)
This PR was merged into the 6.3 branch. Discussion ---------- [Validator] Make exception for all constraints consistent | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a | License | MIT | Doc PR | n/a Let's be sure we're using Validator exception classes everywhere. Commits ------- cab49ef [Validator] Make exception for all constraints consistent
2 parents d4c27d9 + cab49ef commit 1f7bc10
Copy full SHA for 1f7bc10

File tree

3 files changed

+7
-4
lines changed
Filter options

3 files changed

+7
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ChoiceValidator.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\ConstraintValidator;
1616
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
17+
use Symfony\Component\Validator\Exception\RuntimeException;
1718
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1819
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1920

@@ -57,7 +58,7 @@ public function validate(mixed $value, Constraint $constraint)
5758
}
5859

5960
if (true !== $constraint->strict) {
60-
throw new \RuntimeException('The "strict" option of the Choice constraint should not be used.');
61+
throw new RuntimeException('The "strict" option of the Choice constraint should not be used.');
6162
}
6263

6364
if ($constraint->multiple) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/EmailValidator.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
1717
use Symfony\Component\Validator\Constraint;
1818
use Symfony\Component\Validator\ConstraintValidator;
19+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1920
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
2021
use Symfony\Component\Validator\Exception\UnexpectedValueException;
2122

@@ -39,7 +40,7 @@ class EmailValidator extends ConstraintValidator
3940
public function __construct(string $defaultMode = Email::VALIDATION_MODE_LOOSE)
4041
{
4142
if (!\in_array($defaultMode, Email::VALIDATION_MODES, true)) {
42-
throw new \InvalidArgumentException('The "defaultMode" parameter value is not valid.');
43+
throw new InvalidArgumentException('The "defaultMode" parameter value is not valid.');
4344
}
4445

4546
if (Email::VALIDATION_MODE_LOOSE === $defaultMode) {
@@ -81,7 +82,7 @@ public function validate(mixed $value, Constraint $constraint)
8182
}
8283

8384
if (!\in_array($constraint->mode, Email::VALIDATION_MODES, true)) {
84-
throw new \InvalidArgumentException(sprintf('The "%s::$mode" parameter value is not valid.', get_debug_type($constraint)));
85+
throw new InvalidArgumentException(sprintf('The "%s::$mode" parameter value is not valid.', get_debug_type($constraint)));
8586
}
8687

8788
if (Email::VALIDATION_MODE_STRICT === $constraint->mode) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/NotCompromisedPasswordValidator.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpClient\HttpClient;
1515
use Symfony\Component\Validator\Constraint;
1616
use Symfony\Component\Validator\ConstraintValidator;
17+
use Symfony\Component\Validator\Exception\LogicException;
1718
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1819
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1920
use Symfony\Contracts\HttpClient\Exception\ExceptionInterface;
@@ -39,7 +40,7 @@ class NotCompromisedPasswordValidator extends ConstraintValidator
3940
public function __construct(HttpClientInterface $httpClient = null, string $charset = 'UTF-8', bool $enabled = true, string $endpoint = null)
4041
{
4142
if (null === $httpClient && !class_exists(HttpClient::class)) {
42-
throw new \LogicException(sprintf('The "%s" class requires the "HttpClient" component. Try running "composer require symfony/http-client".', self::class));
43+
throw new LogicException(sprintf('The "%s" class requires the "HttpClient" component. Try running "composer require symfony/http-client".', self::class));
4344
}
4445

4546
$this->httpClient = $httpClient ?? HttpClient::create();

0 commit comments

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