Symfony is not loading the correct validation service


Symfony is not loading the correct validation service



I'm using Symfony framework 3.4. Currently i'm working on a validation method, but suddenly Symfony validation stopped working, and then all of my validations stopped working, then i run:


php bin/console debug:container



And i've got the following output for the validator service:


Service ID ClassName
validator alias for "liip_functional_test.validator"



I have the following questions:
Is this the correct class name for the validator service?
What could i have done wrong?



My entire code is this:



namespace AppBundleDataTransfer;

use SymfonyComponentValidatorConstraints as Assert;

class ProductFromApi
{

/**
* @AssertIsTrue(message="Testing the validator")
*/
public function isTestCorrect() : Bool
{
return false;
}
}





I was really puzzled by this override, but after a quick search, I've found out the similar SO question: stackoverflow.com/questions/35876322/…
– Jovan Perovic
2 days ago






Yes, but the problem is that even after i solved the overriding problem the validator still doesn't work. When i run: php bin/console debug:container validator i got the same result as in the answer by: Cameron Hurd
– krionz
2 days ago





I'm not using the validator service directly, i'm using the form->isValid(), and this form should be using the validator service.
– krionz
2 days ago






Could you share a bit more of your config? Maybe service.yml, and excerpts from config.yml you think might be relevant? If the methods in the controller have anything out of the ordinary, it may help to see that, too!
– Cameron Hurd
2 days ago


service.yml


config.yml





Hi, i stopped docker and did docker-compose up again, and now it's working which is weird because i have done: php bin/console cache:clear before. Thank you everyone.
– krionz
yesterday




1 Answer
1



It does look like the service "validator" is an alias for something other than the default symfony validator, doesn't it? (Specifically "liip_functional_test.validator")


validator


liip_functional_test.validator



When I run php bin/console debug:container validator on a Symfony project which I know doesn't have that liip bundle that you've got above, here's what it returns for me:


php bin/console debug:container validator


Information for Service "debug.validator"
=========================================

---------------- ----------------------------------------------------------
Option Value
---------------- ----------------------------------------------------------
Service ID debug.validator
Class SymfonyComponentValidatorValidatorTraceableValidator
Tags kernel.reset (method: reset)
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
---------------- ----------------------------------------------------------



Maybe you want to refer to it as "debug.validator" if you're getting the service out of the DI container by name.


debug.validator



That said you probably shouldn't be calling the validator in that way.



You've got the following in your config.yml, yeah?


config.yml


framework:
validation: { enable_annotations: true }





Yes, i have this YAML on my config.yml. I removed the liip_functional_test.validator bundle from my AppKernel, and then i've got the same output as you did, but the validator is not working.
– krionz
2 days ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift