在 Symfony2 中,可以使用导入将 validation.yml 文件拆分为多个文件吗?2015 年添加的答案
现在,我有一个名为 validation.yml 的文件,其中验证了捆绑包的所有实体在一个文件中。
validation.yml
Blogger\BlogBundle\Entity\Comment
properties:
username:
- NotBlank:
message: You must enter your name
- MaxLength: 50
comment:
- NotBlank:
message: You must enter a comment
- MinLength: 50
Blogger\BlogBundle\Entity\Enquiry:
properties:
name:
- NotBlank: ~
email:
- Email:
message: symblog does not like invalid emails. Give me a real one!
subject:
- NotBlank: ~
- MaxLength: 50
body:
- MinLength: 50
但我想把它分成两个文件并同时导入它们。这是我尝试过的,但它不起作用:
validation.yml
imports:
- { resource: comment.yml }
- { resource: enquiry.yml }
comment.yml
Blogger\BlogBundle\Entity\Comment
properties:
username:
- NotBlank:
message: You must enter your name
- MaxLength: 50
comment:
- NotBlank:
message: You must enter a comment
- MinLength: 50
查询.yml
Blogger\BlogBundle\Entity\Enquiry:
properties:
name:
- NotBlank: ~
email:
- Email:
message: symblog does not like invalid emails. Give me a real one!
subject:
- NotBlank: ~
- MaxLength: 50
body:
- MinLength: 50