diff --git a/src/Rules/Handle.php b/src/Rules/Handle.php index 9a3c06514f..2169ec7596 100644 --- a/src/Rules/Handle.php +++ b/src/Rules/Handle.php @@ -9,7 +9,7 @@ class Handle implements ValidationRule { public function validate(string $attribute, mixed $value, Closure $fail): void { - if (! preg_match('/^[a-zA-Z][a-zA-Z0-9]*(?:_{0,1}[a-zA-Z0-9])*$/', $value)) { + if (! preg_match('/^[a-zA-Z0-9][a-zA-Z0-9]*(?:_{0,1}[a-zA-Z0-9])*$/', $value)) { $fail('statamic::validation.handle')->translate(); } } diff --git a/tests/Rules/HandleTest.php b/tests/Rules/HandleTest.php index 1802979704..1f2e759467 100644 --- a/tests/Rules/HandleTest.php +++ b/tests/Rules/HandleTest.php @@ -23,6 +23,7 @@ public function it_validates_handles() $this->assertPasses('foo123'); $this->assertPasses('foo123_20bar'); $this->assertPasses('FooBar'); + $this->assertPasses('1foo'); $this->assertFails('foo-bar'); $this->assertFails('_foo'); @@ -31,7 +32,6 @@ public function it_validates_handles() $this->assertFails('foo_bar_'); $this->assertFails('foo__bar'); $this->assertFails('foo___bar'); - $this->assertFails('1foo'); $this->assertFails('*foo'); $this->assertFails('foo#'); $this->assertFails('foo_!bar');