Reputation: 12244
I'm learning Symfony2 at a new workplace and was tasked with adding validation to the code which is currently using poor inline based code instead of the Symfony validator and annotations.
I've added validation annotations to my model and added a parameter to my constructor. I've also added an argument to the service.yml so that it gets injected into my bundle's class, but it seems i cannot find the
@validator
as per described in the Symfony documentation (http://symfony.com/doc/current/book/validation.html). If i read the documentation right, i should be able to just add @validator to my services.yml and get it fed directly to my class but when running my tests, it says that the service @validator cannot be found:
The service "ugroup_media_personalization.flattening_service"
has a dependency on a non-existent service "validator"
So what am i doing wrong here?
Upvotes: 0
Views: 291
Reputation: 12244
The problem was that the configuration file for the bundle did not specify the
framework:
validation: {enable_annotations: true}
And thus the framework was not loading the validation service. You can simply use:
framework:
validation:
if you want to trigger the loading the validation module, but in my case, i added enable_annotations to make sure the validation using annotations work!
Upvotes: 1