Skip to content

Commit a3268fe

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 ------- fd7ad234bc do not validate empty values
2 parents e8565b1 + 3bc0bcf commit a3268fe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UserPassword');
4040
}
4141

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

4448
if (!$user instanceof UserInterface) {

0 commit comments

Comments
 (0)