Date range validation with Symfony2

2019-09-14 03:02发布

I want to add a constraint with annotation in Symfony for a date falls within the range, but this range can not be specified explicitly with min. and max. The year should be between the current year (by subtracting the current year or number) and the minimum indicated. For example, if I type a date now must be between 2010/1960, but 2010 should be obtained from the current year-10. This can be done in any way in Symfony?

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-14 03:41

Yes it is possible, you should create a custom validation constraint as explained here :

http://symfony.com/doc/current/cookbook/validation/custom_constraint.html

查看更多
登录 后发表回答