Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Validator] Allow to use translation_domain false for validators and to use custom translation domain by constraints#48852
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedJan 2, 2023
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
carsonbot commentedJan 3, 2023
Hey! I think@norkunas has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Friendly ping@nicolas-grekas, how can I provide BC for this situation ? |
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.
not sure about your questions for BC 😬
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Context/ExecutionContextInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Context/ExecutionContextInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
VincentLanglet commentedJan 9, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
If I change
to
in the
So someone could extends the ValidatorBuilder and override the setTranslationDomain with the "old" signature. If I change
to
in the |
e2e8a1a
toce641ab
Compare25987d1
tob8b0300
Compare
I change my PR to be BC and resolved your request changes@nicolas-grekas :) |
Tests failure doesn't seem related |
Would you have time to take a look/review this@nicolas-grekas@fabpot ? |
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.
Parametervalidator.translation_domain
is also used inFormTypeCsrfExtension
and inUploadValidatorExtension
so I suppose we should make them acceptfalse
also?
How do you expect to disable translation otherwise for builders?
Or maybe this change is not needed for builders?
src/Symfony/Component/Validator/Context/ExecutionContextInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Context/ExecutionContextInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
If this (#48852 (comment)) is a BC break, it cannot be done for Builder then. So validator.translation_domain cannot be set to false, because of the
It's maybe not needed for Builder then ; I removed it. The second BC break (#48852 (comment)) is more annoying ; any way to avoid it but still allowing calling setTranslationDomain(false) ? |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Passing a custom translation domain is already possible through |
src/Symfony/Component/Validator/Context/ExecutionContextInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
May I ask why you need this feature BTW? |
Sure.
But currently, there is no way to use the Validator features without the translator.
would be perfect |
So, we don't need to change addViolation, right? |
Changing
To me |
what's the issue with still processing them through the translator? |
Can't the same argument be used for the option The issue with having them processed by the translator are:
The second point is annoying when you look for all the missing translations, either
|
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
please have a look at this concern please also add needed changelog+upgrade entries
should we update the template so that they use strtr? |
I'm not sure we should support I also think we could avoid changing the signature of If we do these 2 things, it simplifies the code a lot as the ExecutionContext does not need to change anymore and we can add |
This might be a good idea since it would be consistent with the review of this PR and with the behavior of the IdentityTranslator. But I would say it's better to scope this to another PR (that I can do after if wanted).
I agree
Since@nicolas-grekas was thinking the same, I reverted this change. |
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Context/ExecutionContextFactory.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
I squashed the commit and rebase the branch. Is everything ok on this PR@nicolas-grekas ? :) |
LGTM yes, thanks. Can you please add some tests? |
Sure, I added one. Do you think this is enough or is there more to test ? |
…to use custom translation domain by constraints
Thank you@VincentLanglet. |
….disable_translation` option (alexandre-daubois)This PR was merged into the 7.3 branch.Discussion----------[FrameworkBundle][Validator] Add `framework.validation.disable_translation` option| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | _NA_| License | MIT| Doc PR | TodoFollow-up of#48852 and after a suggestion of `@javiereguiluz` [here](symfony/symfony-docs#18325 (comment)).Commits-------98ce3f0 [FrameworkBundle][Validator] Add `framework.validation.disable_translation` config
Currently it's possible to write
but it's not allowed to pass a custom translation_domain (or to disable the translation by passing
false
).Adding a third parameter would allow this. (And changing the
?string
type tostring|false|null
).Wdyt about this feature ? How can we make it fully BC ?