Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac1355d

Browse files
committed
Rename constraint to NoSuspiciousCharacters
1 parent 3e18ec7 commit ac1355d

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CHANGELOG
77
* Add method `getConstraint()` to `ConstraintViolationInterface`
88
* Add `Uuid::TIME_BASED_VERSIONS` to match that a UUID being validated embeds a timestamp
99
* Add the `pattern` parameter in violations of the `Regex` constraint
10-
* Add a `NotSuspicious` constraint to validate a string is not a spoof attempt
10+
* Add a `NoSuspiciousCharacters` constraint to validate a string is not a spoofing attempt
1111

1212
6.2
1313
---

src/Symfony/Component/Validator/Constraints/NotSuspicious.php renamed to src/Symfony/Component/Validator/Constraints/NoSuspiciousCharacters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @author Mathieu Lechat <[email protected]>
2222
*/
2323
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
24-
class NotSuspicious extends Constraint
24+
class NoSuspiciousCharacters extends Constraint
2525
{
2626
/**
2727
* Check that a string satisfies the requirements for the specified restriction level

src/Symfony/Component/Validator/Constraints/NotSuspiciousValidator.php renamed to src/Symfony/Component/Validator/Constraints/NoSuspiciousCharactersValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
/**
2121
* @author Mathieu Lechat <[email protected]>
2222
*/
23-
class NotSuspiciousValidator extends ConstraintValidator implements LocaleAwareInterface
23+
class NoSuspiciousCharactersValidator extends ConstraintValidator implements LocaleAwareInterface
2424
{
2525
private string $locale;
2626

2727
public function validate(mixed $value, Constraint $constraint)
2828
{
29-
if (!$constraint instanceof NotSuspicious) {
30-
throw new UnexpectedTypeException($constraint, NotSuspicious::class);
29+
if (!$constraint instanceof NoSuspiciousCharacters) {
30+
throw new UnexpectedTypeException($constraint, NoSuspiciousCharacters::class);
3131
}
3232

3333
if (null === $value || '' === $value) {

src/Symfony/Component/Validator/Tests/Constraints/NotSuspiciousValidatorTest.php renamed to src/Symfony/Component/Validator/Tests/Constraints/NoSuspiciousCharactersValidatorTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14-
use Symfony\Component\Validator\Constraints\NotSuspicious;
15-
use Symfony\Component\Validator\Constraints\NotSuspiciousValidator;
14+
use Symfony\Component\Validator\Constraints\NoSuspiciousCharacters;
15+
use Symfony\Component\Validator\Constraints\NoSuspiciousCharactersValidator;
1616
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1717

1818
/**
1919
* @requires extension intl
2020
*
21-
* @extends ConstraintValidatorTestCase<NotSuspiciousValidator>
21+
* @extends ConstraintValidatorTestCase<NoSuspiciousCharactersValidator>
2222
*/
23-
class NotSuspiciousValidatorTest extends ConstraintValidatorTestCase
23+
class NoSuspiciousCharactersValidatorTest extends ConstraintValidatorTestCase
2424
{
25-
protected function createValidator(): NotSuspiciousValidator
25+
protected function createValidator(): NoSuspiciousCharactersValidator
2626
{
27-
$validator = new NotSuspiciousValidator();
27+
$validator = new NoSuspiciousCharactersValidator();
2828
$validator->setLocale(\Locale::getDefault());
2929

3030
return $validator;
3131
}
3232

3333
public function testNonSuspiciousStrings()
3434
{
35-
$this->validator->validate('à', new NotSuspicious());
35+
$this->validator->validate('à', new NoSuspiciousCharacters());
3636

3737
$this->assertNoViolation();
3838
}
@@ -42,7 +42,7 @@ public function testNonSuspiciousStrings()
4242
*/
4343
public function testSuspiciousStrings(string $string, array $options)
4444
{
45-
$this->validator->validate($string, new NotSuspicious(['message' => 'myMessage'] + $options));
45+
$this->validator->validate($string, new NoSuspiciousCharacters(['message' => 'myMessage'] + $options));
4646

4747
$this->buildViolation('myMessage')
4848
->setParameter('{{ value }}', '"'.$string.'"')
@@ -67,21 +67,21 @@ public static function provideSuspiciousStrings(): iterable
6767
'profileLocales' => ['el_GR'],
6868
]];
6969
yield 'Fails restriction level check because of Greek script absent from profile' => ['àπ', [
70-
'checks' => NotSuspicious::CHECK_RESTRICTION_LEVEL,
70+
'checks' => NoSuspiciousCharacters::CHECK_RESTRICTION_LEVEL,
7171
'restrictionLevel' => \Spoofchecker::MINIMALLY_RESTRICTIVE,
7272
]];
7373

7474
yield 'Fails INVISIBLE check because of duplicated non-spacing mark' => ['à̀', [
75-
'checks' => NotSuspicious::CHECK_INVISIBLE,
75+
'checks' => NoSuspiciousCharacters::CHECK_INVISIBLE,
7676
]];
7777
yield 'Fails CHAR_LIMIT check because of Greek script absent from profile' => ['àπ', [
78-
'checks' => NotSuspicious::CHECK_CHAR_LIMIT,
78+
'checks' => NoSuspiciousCharacters::CHECK_CHAR_LIMIT,
7979
]];
8080
yield 'Fails MIXED_NUMBERS check because of different numbering systems' => ['8৪', [
81-
'checks' => NotSuspicious::CHECK_MIXED_NUMBERS,
81+
'checks' => NoSuspiciousCharacters::CHECK_MIXED_NUMBERS,
8282
]];
8383
yield 'Fails HIDDEN_OVERLAY check because of hidden combining character' => ['', [
84-
'checks' => NotSuspicious::CHECK_HIDDEN_OVERLAY,
84+
'checks' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY,
8585
]];
8686
}
8787
}

0 commit comments

Comments
 (0)