Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit77d06b5

Browse files
committed
bug#23341 [DoctrineBridge][Security][Validator] do not validate empty values (xabbuh)
This PR was merged into the 2.7 branch.Discussion----------[DoctrineBridge][Security][Validator] do not validate empty values| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#23319| License | MIT| Doc PR |Nearly all validators operating on scalar values (except for some special constraints) do ignore empty values. If you want to forbid them, you have to use the `NotBlank` constraint instead.Commits-------fd7ad23 do not validate empty values
2 parents4e65c1f +fd7ad23 commit77d06b5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

‎src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function validate($entity, Constraint $constraint)
6262
thrownewConstraintDefinitionException('At least one field has to be specified.');
6363
}
6464

65+
if (null ===$entity) {
66+
return;
67+
}
68+
6569
if ($constraint->em) {
6670
$em =$this->registry->getManager($constraint->em);
6771

‎src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public function validate($password, Constraint $constraint)
3939
thrownewUnexpectedTypeException($constraint,__NAMESPACE__.'\UserPassword');
4040
}
4141

42+
if (null ===$password ||'' ===$password) {
43+
return;
44+
}
45+
4246
$user =$this->tokenStorage->getToken()->getUser();
4347

4448
if (!$userinstanceof UserInterface) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint)
4848
thrownewUnexpectedTypeException($constraint,__NAMESPACE__.'\Url');
4949
}
5050

51-
if (null ===$value) {
51+
if (null ===$value ||'' ===$value) {
5252
return;
5353
}
5454

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp