Skip to content

fix(product-data): update slug generation to match pattern#813

Merged
ahmehri merged 2 commits into
mainfrom
am-fix-product-slug-must-match-pattern
May 19, 2025
Merged

fix(product-data): update slug generation to match pattern#813
ahmehri merged 2 commits into
mainfrom
am-fix-product-slug-must-match-pattern

Conversation

@ahmehri
Copy link
Copy Markdown
Contributor

@ahmehri ahmehri commented May 13, 2025

This pull request introduces stricter validation and updated configurations for the slug field in both REST and GraphQL models. The changes ensure that slugs follow a specific pattern and use predefined presets for consistency.

Validation updates:

  • standalone/src/models/product/product-data/builders.spec.ts: Updated the slug field validation in both validateRestModel and validateGraphqlModel functions to enforce a stricter regex pattern (/^[A-Za-z0-9_-]{2,256}$/). This ensures slugs are alphanumeric with optional underscores or hyphens, and have a length between 2 and 256 characters. [1] [2]

Configuration updates:

  • standalone/src/models/product/product-data/fields-config.ts: Replaced LocalizedString.random() with LocalizedString.presets.ofSlugs() for the slug field in both restFieldsConfig and graphqlFieldsConfig. This change ensures that slugs are generated using predefined presets for better consistency and alignment with the validation rules. [1] [2]

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2025

🦋 Changeset detected

Latest commit: d13b0c1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@commercetools/composable-commerce-test-data Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ahmehri ahmehri self-assigned this May 13, 2025
@ahmehri ahmehri marked this pull request as ready for review May 13, 2025 08:13
@ahmehri ahmehri requested a review from a team as a code owner May 13, 2025 08:13
@ahmehri ahmehri added the bug Something isn't working label May 13, 2025
Copy link
Copy Markdown
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

Good catch, thanks!

@ahmehri ahmehri merged commit fddc2a7 into main May 19, 2025
8 checks passed
@ahmehri ahmehri deleted the am-fix-product-slug-must-match-pattern branch May 19, 2025 15:11
@ct-changesets ct-changesets Bot mentioned this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants