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
Fix product review validation's notInRangeMessage #14584
Fix product review validation's notInRangeMessage #14584
Conversation
500fdc8
to
6bed76a
Compare
@@ -100,8 +100,6 @@ sylius: | |||
review: | |||
author: | |||
not_blank: Bitte geben Sie Ihre E-Mail-Adresse ein. | |||
rating: | |||
range: Bewertung muss eine Ganzzahl im Bereich 1-5 sein. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it should be removed from all locales (idk how to forward the change to crowdin)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's already removed from all locales, just a few of them had that translation defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ cd src/Sylius/Bundle/CoreBundle/Resources/translations
$ ag -i range
validators.en.yml
117: not_in_range: Review rating must be between {{ min }} and {{ max }}.
…(diimpp, GSadee) This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | 1.11 | | Bug fix? | yes | | New feature? | no | | BC breaks? | no | | Deprecations? | yes | | Related tickets | fixes #13883 | | License | MIT | **Issue** Symfony validation constraint [`Range`](https://symfony.com/doc/4.4/reference/constraints/Range.html#notinrangemessage) instroduced new behavior since 4.4 release -- if both `min` and `max` options are defined, then `notInRangeMessage` will be shown and `minMessage`/`maxMessage` will be disregarded. <details><summary>Example</summary> If you will try to generate coupons for promotion with code length larger than 40, then you will see symfony standard message `notInRangeMessage: This value should be between {{ min }} and {{ max }}.` instead of sylius `maxMessage: Coupon code must not be longer than {{ limit }} characters.` ![image](https://user-images.githubusercontent.com/870747/203878039-2d6ac8c3-130c-4758-a7ae-bd638817faf7.png) </details> #### Case 1 https://github.com/Sylius/Sylius/blob/9506c80f2080b34b89f51b54e7e8f3490c8b7d36/src/Sylius/Bundle/PromotionBundle/Resources/config/validation/PromotionCouponGeneratorInstruction.xml#L33-L37 - [x] Remove minMessage, maxMessage and their translations - [x] Introduce notInRangeMessage and new translation - [x] Cover case with behat scenario #### Case 2 https://github.com/Sylius/Sylius/blob/9506c80f2080b34b89f51b54e7e8f3490c8b7d36/src/Sylius/Bundle/PromotionBundle/Form/Type/Action/UnitPercentageDiscountConfigurationType.php#L35-L41 - [x] Remove minMessage, maxMessage usage; Their translations were already removed. - [x] Introduce notInRangeMessage; Translation already exists as it's shared between order/item percentage discount - [x] Cover case with behat scenario #### Case 3 https://github.com/Sylius/Sylius/blob/9506c80f2080b34b89f51b54e7e8f3490c8b7d36/src/Sylius/Bundle/ApiBundle/Resources/config/validation/AddProductReview.xml#L23-L28 - [x] Remove minMessage, maxMessage - [x] Rename translation key `range` to `not_in_range` - [x] Move to separate #14584 due deprecation. **Questions** 1. Does removal of `sylius.promotion_coupon_generator_instruction.code_length.min` and `...max` messages constitute a deprecation entry? Because those translation strings were inactive (effectively deprecated by symfony upgrade) since project was upgraded to symfony 4.4 and even if somebody has custom translation over there, it has no effect whatsoever. 2. Please advise on adding/removal of translation strings, do I need to do anything else? I do recall some translation service was in use. Commits ------- f1ae3df Set correct notInRangeMessage for coupon generation validation f55babd Set correct notInRangeMessage for unit percentage discount promotion action 7d88a38 [Behat] Add minor improvements to range validations fixes 63e8b69 [Promotion] Revert removing min and max validation messages for code length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @diimpp, could you keep sylius.review.rating.range
instead of defining the new sylius.review.rating.not_in_range
? If so, the PR is mergeable IMO. Thanks!
Hi, but correct string is |
@diimpp Yeah, good idea. Would be great to leave that one and introduce a new one. |
0d3abb7
to
8c682d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
Thanks for your work. I've restored the old key to behave BC compatibility, in case someone is using it elsewhere :).
8c682d1
to
4bada6d
Compare
Thank you, @diimpp! |
Continuation of #14576 based on 1.13 due deprecation and changes introduced in 1.12
Range constraints doesn't validate for integer type, so I've removed mention of this and was forced to remove translated strings from other languages.