Date range validation with Symfony2

╄→尐↘猪︶ㄣ 提交于 2019-12-12 02:23:34

问题


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:


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

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



来源:https://stackoverflow.com/questions/34185153/date-range-validation-with-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!