在 yml 文件中添加验证约束之前有什么需要做的。我很难找到有关如何加载validation.yml文件的文档信息:
# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
properties:
firstName:
- NotBlank: ~
- MinLength: 3
从验证文件加载验证约束的过程是什么?
编辑
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);
}