21
21
*/
22
22
class NoSuspiciousCharactersValidator extends ConstraintValidator
23
23
{
24
+ private const CHECK_CHAR_LIMIT = 64 ;
25
+
24
26
private const CHECK_ERROR = [
25
27
NoSuspiciousCharacters::CHECK_RESTRICTION_LEVEL => [
26
28
'code ' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR ,
@@ -30,7 +32,7 @@ class NoSuspiciousCharactersValidator extends ConstraintValidator
30
32
'code ' => NoSuspiciousCharacters::INVISIBLE_ERROR ,
31
33
'messageProperty ' => 'invisibleMessage ' ,
32
34
],
33
- NoSuspiciousCharacters ::CHECK_CHAR_LIMIT => [
35
+ self ::CHECK_CHAR_LIMIT => [
34
36
'code ' => NoSuspiciousCharacters::CHAR_LIMIT_ERROR ,
35
37
'messageProperty ' => 'charLimitMessage ' ,
36
38
],
@@ -74,7 +76,11 @@ public function validate(mixed $value, Constraint $constraint)
74
76
if ($ constraint ->restrictionLevel ) {
75
77
$ checker ->setRestrictionLevel ($ constraint ->restrictionLevel );
76
78
}
77
- $ checker ->setAllowedLocales (implode (', ' , $ constraint ->locales ?? $ this ->defaultLocales ));
79
+
80
+ if ($ allowedLocales = $ constraint ->locales ?? $ this ->defaultLocales ) {
81
+ $ checker ->setAllowedLocales ($ allowedLocales );
82
+ $ constraint ->checks &= self ::CHECK_CHAR_LIMIT ;
83
+ }
78
84
79
85
$ checker ->setChecks ($ constraint ->checks );
80
86
0 commit comments