0

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 AppBundle\DataTransfer;

use Symfony\Component\Validator\Constraints as Assert;

class ProductFromApi
{

   /**
     * @Assert\IsTrue(message="Testing the validator")
     */
    public function isTestCorrect() : Bool
    {
        return false;
    }
}
krionz
  • 417
  • 1
  • 4
  • 15
  • I was really puzzled by this override, but after a quick search, I've found out the similar SO question: https://stackoverflow.com/questions/35876322/symfony2-liipfunctionaltestbundle-overriding-validator-service – Jovan Perovic Jun 28 '18 at 22:02
  • 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 Jun 29 '18 at 01:13
  • I'm not using the validator service directly, i'm using the form->isValid(), and this form should be using the validator service. – krionz Jun 29 '18 at 01:14
  • 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 Jun 29 '18 at 15:08
  • 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 Jun 29 '18 at 20:30

1 Answers1

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")

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:

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

 ---------------- ----------------------------------------------------------
  Option           Value
 ---------------- ----------------------------------------------------------
  Service ID       debug.validator
  Class            Symfony\Component\Validator\Validator\TraceableValidator
  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.

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

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

framework:
    validation: { enable_annotations: true }
Cameron Hurd
  • 4,836
  • 1
  • 22
  • 31
  • 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 Jun 28 '18 at 21:16