現在,我有一個名爲validation.yml的文件,在一個文件中驗證所有包的實體。在Symfony2中,可以使用導入將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
enquiry.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
你是什麼意思 「沒有工作」 ?是拋出異常還是什麼都沒有發生? – Problematic 2012-02-22 21:49:33
提交的表單未經正確驗證,不應該發生。 – intrepion 2012-02-22 23:50:03