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

[Validator] let theSlugValidator acceptAsciiSlugger results#60426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:7.3fromxabbuh:pr-58542
May 16, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsrc/Symfony/Component/Validator/Constraints/Slug.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ class Slug extends Constraint
public const NOT_SLUG_ERROR = '14e6df1e-c8ab-4395-b6ce-04b132a3765e';

public string $message = 'This value is not a valid slug.';
public string $regex = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/';
public string $regex = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/i';

#[HasNamedArguments]
public function __construct(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@

namespace Symfony\Component\Validator\Tests\Constraints;

use Symfony\Component\String\Slugger\AsciiSlugger;
use Symfony\Component\Validator\Constraints\Slug;
use Symfony\Component\Validator\Constraints\SlugValidator;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
Expand DownExpand Up@@ -47,6 +48,7 @@ public function testExpectsStringCompatibleType()
* @testWith ["test-slug"]
* ["slug-123-test"]
* ["slug"]
* ["TestSlug"]
*/
public function testValidSlugs($slug)
{
Expand All@@ -56,8 +58,7 @@ public function testValidSlugs($slug)
}

/**
* @testWith ["NotASlug"]
* ["Not a slug"]
* @testWith ["Not a slug"]
* ["not-á-slug"]
* ["not-@-slug"]
*/
Expand DownExpand Up@@ -91,7 +92,7 @@ public function testCustomRegexInvalidSlugs($slug)

/**
* @testWith ["slug"]
*@testWith ["test1234"]
* ["test1234"]
*/
public function testCustomRegexValidSlugs($slug)
{
Expand All@@ -101,4 +102,16 @@ public function testCustomRegexValidSlugs($slug)

$this->assertNoViolation();
}

/**
* @testWith ["PHP"]
* ["Symfony is cool"]
* ["Lorem ipsum dolor sit amet"]
*/
public function testAcceptAsciiSluggerResults(string $text)
{
$this->validator->validate((new AsciiSlugger())->slug($text), new Slug());

$this->assertNoViolation();
}
}
1 change: 1 addition & 0 deletionssrc/Symfony/Component/Validator/composer.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@
"symfony/mime": "^6.4|^7.0",
"symfony/property-access": "^6.4|^7.0",
"symfony/property-info": "^6.4|^7.0",
"symfony/string": "^6.4|^7.0",
"symfony/translation": "^6.4.3|^7.0.3",
"symfony/type-info": "^7.1",
"egulias/email-validator": "^2.1.10|^3|^4"
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp