File tree 3 files changed +18
-4
lines changed
src/Symfony/Component/Validator 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class Slug extends Constraint
25
25
public const NOT_SLUG_ERROR = '14e6df1e-c8ab-4395-b6ce-04b132a3765e ' ;
26
26
27
27
public string $ message = 'This value is not a valid slug. ' ;
28
- public string $ regex = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/ ' ;
28
+ public string $ regex = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/i ' ;
29
29
30
30
#[HasNamedArguments]
31
31
public function __construct (
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Validator \Tests \Constraints ;
13
13
14
+ use Symfony \Component \String \Slugger \AsciiSlugger ;
14
15
use Symfony \Component \Validator \Constraints \Slug ;
15
16
use Symfony \Component \Validator \Constraints \SlugValidator ;
16
17
use Symfony \Component \Validator \Exception \UnexpectedValueException ;
@@ -47,6 +48,7 @@ public function testExpectsStringCompatibleType()
47
48
* @testWith ["test-slug"]
48
49
* ["slug-123-test"]
49
50
* ["slug"]
51
+ * ["TestSlug"]
50
52
*/
51
53
public function testValidSlugs ($ slug )
52
54
{
@@ -56,8 +58,7 @@ public function testValidSlugs($slug)
56
58
}
57
59
58
60
/**
59
- * @testWith ["NotASlug"]
60
- * ["Not a slug"]
61
+ * @testWith ["Not a slug"]
61
62
* ["not-á-slug"]
62
63
* ["not-@-slug"]
63
64
*/
@@ -91,7 +92,7 @@ public function testCustomRegexInvalidSlugs($slug)
91
92
92
93
/**
93
94
* @testWith ["slug"]
94
- * @testWith ["test1234"]
95
+ * ["test1234"]
95
96
*/
96
97
public function testCustomRegexValidSlugs ($ slug )
97
98
{
@@ -101,4 +102,16 @@ public function testCustomRegexValidSlugs($slug)
101
102
102
103
$ this ->assertNoViolation ();
103
104
}
105
+
106
+ /**
107
+ * @testWith ["PHP"]
108
+ * ["Symfony is cool"]
109
+ * ["Lorem ipsum dolor sit amet"]
110
+ */
111
+ public function testAcceptAsciiSluggerResults (string $ text )
112
+ {
113
+ $ this ->validator ->validate ((new AsciiSlugger ())->slug ($ text ), new Slug ());
114
+
115
+ $ this ->assertNoViolation ();
116
+ }
104
117
}
Original file line number Diff line number Diff line change 38
38
"symfony/mime" : " ^6.4|^7.0" ,
39
39
"symfony/property-access" : " ^6.4|^7.0" ,
40
40
"symfony/property-info" : " ^6.4|^7.0" ,
41
+ "symfony/string" : " ^6.4|^7.0" ,
41
42
"symfony/translation" : " ^6.4.3|^7.0.3" ,
42
43
"symfony/type-info" : " ^7.1" ,
43
44
"egulias/email-validator" : " ^2.1.10|^3|^4"
You can’t perform that action at this time.
0 commit comments