0

Possible Duplicate:
In Symfony2, can the validation.yml file be split into multiple files using imports?

Is there anything that need to be done before adding validation constraints in a yml file. I struggle finding information on the doc on how to load validation.yml file:

# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
    properties:
        firstName:
            - NotBlank: ~
            - MinLength: 3

What is the procedure to load validation constraints from a validation file?

EDIT

public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);

    $ymlValidationFile = $container  ->getParameter('validator.mapping.loader.yaml_files_loader.mapping_files');
    $ymlValidationFile[] = __DIR__.'/../Resources/config/validation.yml';
        $container->setParameter('validator.mapping.loader.yaml_files_loader.mapping_files',$ymlValidationFile);
}
Community
  • 1
  • 1
Tom
  • 69
  • 1
  • 6
  • This [answer](http://stackoverflow.com/a/9414343/970721) explains everything you need – Vitalii Zurian Jul 30 '12 at 10:46
  • Awesome, now, is there a trick to check that the file is being read? I have updated my question with what I have done. Does this sound good to you? I couldn't find any relevant info on the doc regarding this, do you know where I could learn from this dep injection for validation? Thanks – Tom Jul 30 '12 at 10:55
  • Have you read [this article](http://symfony.com/doc/current/cookbook/bundles/extension.html)? – Vitalii Zurian Jul 30 '12 at 11:02
  • nope, thanks! post a reply so that I can accept it :-) – Tom Jul 30 '12 at 11:09
  • Is there a way to load validation.yml directly in config.yml without using semantic configuration? I tried import, but I have an error message? – Tom Jul 30 '12 at 11:11
  • And, of course, you've read [this](http://symfony.com/doc/current/book/validation.html)? :) – Vitalii Zurian Jul 30 '12 at 11:14

1 Answers1

1

I think, this beautiful doc fully explains your questions :)

Vitalii Zurian
  • 17,858
  • 4
  • 64
  • 81