Skip to content

Replace Validate:: method names with Symfony Constraint objects in demoextrafield#251

Open
Jeremie-Kiwik wants to merge 1 commit into
PrestaShop:masterfrom
Jeremie-Kiwik:pr-demoextrafield-constraints
Open

Replace Validate:: method names with Symfony Constraint objects in demoextrafield#251
Jeremie-Kiwik wants to merge 1 commit into
PrestaShop:masterfrom
Jeremie-Kiwik:pr-demoextrafield-constraints

Conversation

@Jeremie-Kiwik

Copy link
Copy Markdown
Contributor
Questions Answers
Branch? master
Description? ExtraPropertyDefinition::$validator (a Validate:: method name string) was replaced upstream by $constraints (a list of real Symfony\Component\Validator\Constraint instances) — see PrestaShop/PrestaShop#41806 / issue #41544. This module's registrations are adjusted accordingly
Type? refacto
Category? BO
BC breaks? no
Deprecations? no
How to test? 1. Install demoextrafield on a core that includes PrestaShop/PrestaShop#41806 (required/constraints already merged into develop). 2. Verify the installation succeeds (no error registering the ExtraPropertyDefinitions). 3. Test each constrained field from the BO product/category/customer forms: video_link (invalid URL rejected), custom_date (invalid date rejected), theme_color (empty value rejected + invalid color rejected), marketing_note (injected script/iframe rejected), id_supplier/credit_limit (negative value rejected), delivery_note/promo_banner/revision_code (<>{} characters rejected). 4. Verify is_dangerous (bool) and extra_json (JSON) still work normally.
UI Tests N/A
Fixed issue or discussion? Related to PrestaShop/PrestaShop#41544 (no issue opened specifically on example-modules)
Related PRs Depends on PrestaShop/PrestaShop#41806 (feat/41544-extra-property-constraints, already merged into develop)
Sponsor company Kiwik

Detail of the changes

  • video_link (isUrl) → Url
  • custom_date (isDate) → Date
  • marketing_note (isCleanHtml) → CleanHtml (PrestaShop constraint introduced by the same core refactor)
  • delivery_note / promo_banner / revision_code (isGenericName) → TypedRegex(TYPE_GENERIC_NAME) (PrestaShop constraint, same regex as the legacy method)
  • id_supplier (isUnsignedId) / credit_limit (isPrice) → PositiveOrZero (closest available constraint; does not reproduce the exact digit/decimal format of the legacy regex)
  • theme_color (isColor) → Regex with the same hex-or-named-color pattern (no Symfony/PrestaShop constraint covers this case)
  • is_dangerous (isBool) → no constraint (the BOOL column type + the caster already guarantee the right shape)

Also renames formRequiredrequired (same rename on the core side), and fixes a comment claiming that required: true automatically adds a NotBlank constraint — that's no longer the case; theme_color now passes NotBlank explicitly to keep the same actual level of validation.

…moextrafield

ExtraPropertyDefinition's $validator (Validate:: method name string) was replaced
upstream by $constraints (list of real Symfony\Validator\Constraint instances).
Adjust all registrations accordingly:

- isUrl -> Url, isJson -> Json, isDate -> Date (vanilla Symfony constraints)
- isCleanHtml -> CleanHtml, isGenericName -> TypedRegex(TYPE_GENERIC_NAME)
  (PrestaShop constraints introduced by the same upstream refactor)
- isUnsignedId / isPrice -> PositiveOrZero (closest equivalent; does not enforce
  the exact legacy digit/decimal format)
- isColor -> Regex with the same hex-or-named-color pattern (no Symfony/PS
  constraint covers this case)
- isBool dropped entirely: the BOOL column type + value caster already
  guarantee the right shape, no constraint adds value here

Also renamed formRequired -> required (same upstream rename) and updated the
theme_color comment: required no longer auto-adds a NotBlank constraint, so one
is now passed explicitly alongside the color Regex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant