Replace Validate:: method names with Symfony Constraint objects in demoextrafield#251
Open
Jeremie-Kiwik wants to merge 1 commit into
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
masterExtraPropertyDefinition::$validator(aValidate::method name string) was replaced upstream by$constraints(a list of realSymfony\Component\Validator\Constraintinstances) — see PrestaShop/PrestaShop#41806 / issue #41544. This module's registrations are adjusted accordinglydemoextrafieldon a core that includes PrestaShop/PrestaShop#41806 (required/constraintsalready merged intodevelop). 2. Verify the installation succeeds (no error registering theExtraPropertyDefinitions). 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. Verifyis_dangerous(bool) andextra_json(JSON) still work normally.feat/41544-extra-property-constraints, already merged intodevelop)Detail of the changes
video_link(isUrl) →Urlcustom_date(isDate) →Datemarketing_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) →Regexwith 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
formRequired→required(same rename on the core side), and fixes a comment claiming thatrequired: trueautomatically adds aNotBlankconstraint — that's no longer the case;theme_colornow passesNotBlankexplicitly to keep the same actual level of validation.