Skip to content

Navigation Menu

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

Appearance settings

[Validator] Add Slug constraint #58542

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Conversation

raffaelecarelle
Copy link
Contributor

@raffaelecarelle raffaelecarelle commented Oct 11, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Introduce Slug constraint class for validating strings as slugs.
Add unit tests to verify correct behavior for valid and invalid slugs.

@raffaelecarelle raffaelecarelle requested a review from stof December 21, 2024 16:27
Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test with a custom regex?

@raffaelecarelle
Copy link
Contributor Author

Can you add a test with a custom regex?

Done

@fabpot
Copy link
Member

fabpot commented Jan 6, 2025

Thank you @raffaelecarelle.

@fabpot fabpot merged commit 18d08ff into symfony:7.3 Jan 6, 2025
9 checks passed
@Kocal
Copy link
Member

Kocal commented Apr 29, 2025

Hey, are we fine with (new AsciiSlugger())->slug('My article title') failing to be asserted by this new Slug assertion, since the generated slug is My-article-title, with an uppercase character?

{
public const NOT_SLUG_ERROR = '14e6df1e-c8ab-4395-b6ce-04b132a3765e';

public string $message = 'This value is not a valid slug.';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message needs to be added in translation files (so that the translators from the community can provide translations for it in core, like other default messages of constraints)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has already been done in #59383

@xabbuh
Copy link
Member

xabbuh commented May 15, 2025

@Kocal see #60426

nicolas-grekas added a commit that referenced this pull request May 16, 2025
…results (xabbuh)

This PR was merged into the 7.3 branch.

Discussion
----------

[Validator] let the `SlugValidator` accept `AsciiSlugger` results

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #58542 (comment)
| License       | MIT

Commits
-------

d51f563 let the SlugValidator accept AsciiSlugger results
symfony-splitter pushed a commit to symfony/validator that referenced this pull request May 16, 2025
…results (xabbuh)

This PR was merged into the 7.3 branch.

Discussion
----------

[Validator] let the `SlugValidator` accept `AsciiSlugger` results

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | Fix symfony/symfony#58542 (comment)
| License       | MIT

Commits
-------

d51f563ed3c let the SlugValidator accept AsciiSlugger results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.