Sne*_*lle 3 annotations symfony symfony-validator
我正在尝试比较验证中的日期.文档说这是可能的,但没有记录.我正在使用注释,我希望一个日期晚于另一个.我该怎么做呢?
我最终使用这样的表达式解决了它:
/**
* @var \Datetime
* @Assert\Type(
* type = "\DateTime",
* message = "vacancy.date.valid",
* )
* @Assert\GreaterThanOrEqual(
* value = "today",
* message = "vacancy.date.not_today"
* )
*/
private $startdate;
/**
* @var \Datetime
* @Assert\Type(
* type = "\DateTime",
* message = "vacancy.date.valid",
* )
* @Assert\GreaterThanOrEqual(
* value = "today",
* message = "vacancy.date.not_today"
* )
* @Assert\Expression(
* "this.getEnddate() >= this.getStartdate()",
* message="vacancy.date.not_more_than"
* )
*/
private $enddate;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2133 次 |
| 最近记录: |