Skip to content

[Validator] There is no way to add custom validator loader since symfony 2.5 #18930

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

Closed
hurricane-voronin opened this issue Jun 1, 2016 · 8 comments

Comments

@hurricane-voronin
Copy link
Contributor

Hi,
Relates to the issue #9144.
Since symfony 2.5 there is no way to add custom validator loader.

Could you help with this?

@xabbuh
Copy link
Member

xabbuh commented Jan 13, 2017

@hurricane-voronin Can you explain the problem you face in more detail? What do you try to solve and why does it not work?

@jakzal
Copy link
Contributor

jakzal commented Feb 7, 2017

@hurricane-voronin any feedback?

@hurricane-voronin
Copy link
Contributor Author

Hi there,
I have validation rules that stored in the database and could be configured dynamically, e.g I am able to create additional entities, configure/add fields and validation rules for them from the application UI. To load these configs I needed to add a custom validator loader that allow me to do this.

@xabbuh
Copy link
Member

xabbuh commented Feb 7, 2017

That explains what you are trying to do. But it's still not clear to me how you tried to solve your issue and where you were stuck or what did not work.

@hurricane-voronin
Copy link
Contributor Author

Before 9b204c93544532ebac27e6b500de22a2599fab7e changes there was a possibility to add custom validator loader to \Symfony\Component\Validator\Mapping\Loader\LoaderChain through compiler pass, as it was declared as service.

For now as a workaround, the easiest way is to override ValidatorBuilder, that is not a good approach.
Is it valid changes in 9b204c93544532ebac27e6b500de22a2599fab7e , may some changes should be reverted or I have to find a different way to resolve my problem?

@xabbuh
Copy link
Member

xabbuh commented Feb 8, 2017

There is indeed to other way than replacing the validator.builder service. However, I do not think the use case is common enough to justify its own extension point.

@stof
Copy link
Member

stof commented Aug 17, 2018

Well, the fact that we use this ValidatorBuilder to instantiate loaders instead of using the DIC means we don't allow using the container extension points (compiler passes) to hook into this. That's the only component where we do this.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Aug 17, 2018

ValidatorBuilder::addLoader() is part of #28210

@fabpot fabpot closed this as completed Sep 3, 2018
fabpot added a commit that referenced this issue Sep 3, 2018
…uple symfony/validator from symfony/translation (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Contracts] Add Translation\TranslatorInterface + decouple symfony/validator from symfony/translation

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #15714, #18930
| License       | MIT
| Doc PR        | -

Let's decouple Validator from Translation component \o/!

TODO:
- [x] add `TranslatorInterface`, deprecate it from Translation
- [x] add `TranslatorTrait`, deprecating `MessageSelector`, `Internal` and `PluralizationRules`
- [x] deprecate `ValidatorBuilderInterface(LegacyTranslatorInterface)`
- [x] inject a new `identity_translator` into `translator.formatter.default`, deprecate `translator.selector`
- [x] copy tests in the Contracts namespace to ensure the `TranslatorTrait` behaves properly
- [x] figure out a way to keep throwing `InvalidArgumentException` from the component
- [x] update UPGRADING and CHANGELOG files
- [x] polish the deprecation layer (ensure all needed runtime deprecations are here)

Reviews welcome already.

Commits
-------

064e369 [Contracts] Add Translation\TranslatorInterface + decouple symfony/validator from symfony/translation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants