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

Commitf082e56

Browse files
feature#54479 [Validator] set the password strength as a violation parameter (xabbuh)
This PR was merged into the 7.1 branch.Discussion----------[Validator] set the password strength as a violation parameter| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | yes| Deprecations? | no| Issues |Fix#54405 (review)| License | MITCommits-------306f29e set the password strength as a violation parameter
2 parents4ce4e5e +306f29e commitf082e56

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

‎src/Symfony/Component/Validator/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.1
55
---
66

7+
* Add the calculated strength to violations in`PasswordStrengthValidator`
78
* Add support for`Stringable` values when using the`Cidr`,`CssColor`,`ExpressionSyntax` and`PasswordStrength` constraints
89
* Add`MacAddress` constraint
910
* Add`*_NO_PUBLIC`,`*_ONLY_PRIVATE` and`*_ONLY_RESERVED` versions to`Ip` constraint

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function validate(#[\SensitiveParameter] mixed $value, Constraint $constr
4545
if ($strength <$constraint->minScore) {
4646
$this->context->buildViolation($constraint->message)
4747
->setCode(PasswordStrength::PASSWORD_STRENGTH_ERROR)
48+
->setParameter('{{ strength }}',$strength)
4849
->addViolation();
4950
}
5051
}

‎src/Symfony/Component/Validator/Tests/Constraints/PasswordStrengthValidatorTest.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function testValidValues(string|\Stringable $value, int $expectedStrength
4040

4141
$this->buildViolation('The password strength is too low. Please use a stronger password.')
4242
->setCode(PasswordStrength::PASSWORD_STRENGTH_ERROR)
43+
->setParameter('{{ strength }}',$expectedStrength)
4344
->assertRaised();
4445
}
4546

@@ -55,13 +56,15 @@ public static function getValidValues(): iterable
5556
/**
5657
* @dataProvider provideInvalidConstraints
5758
*/
58-
publicfunctiontestThePasswordIsWeak(PasswordStrength$constraint,string$password,string$expectedMessage,string$expectedCode,array$parameters = [])
59+
publicfunctiontestThePasswordIsWeak(PasswordStrength$constraint,string$password,string$expectedMessage,string$expectedCode,string$strength)
5960
{
6061
$this->validator->validate($password,$constraint);
6162

6263
$this->buildViolation($expectedMessage)
6364
->setCode($expectedCode)
64-
->setParameters($parameters)
65+
->setParameters([
66+
'{{ strength }}' =>$strength,
67+
])
6568
->assertRaised();
6669
}
6770

@@ -72,18 +75,21 @@ public static function provideInvalidConstraints(): iterable
7275
'password',
7376
'The password strength is too low. Please use a stronger password.',
7477
PasswordStrength::PASSWORD_STRENGTH_ERROR,
78+
'0',
7579
];
7680
yield [
7781
newPasswordStrength(minScore: PasswordStrength::STRENGTH_VERY_STRONG),
7882
'Good password?',
7983
'The password strength is too low. Please use a stronger password.',
8084
PasswordStrength::PASSWORD_STRENGTH_ERROR,
85+
'1',
8186
];
8287
yield [
8388
newPasswordStrength(message:'This password should be strong.'),
8489
'password',
8590
'This password should be strong.',
8691
PasswordStrength::PASSWORD_STRENGTH_ERROR,
92+
'0',
8793
];
8894
}
8995
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp