【发布时间】:2017-02-21 13:37:47
【问题描述】:
假设我有一个实体 Travel,其字符串属性为 destination,其长度应为 100 个字符:
Travel.php:
class Travel{
...
/**
*
* @var string
*/
private $destination;
...
}
我已经在Travel.orm.yml 中定义了长度:
Project\Bundle\MyBundle\Entity\Travel:
...
fields:
...
destination:
type: string
length: 100
现在我在validation.yml 中手动设置验证值:
Project\Bundle\MyBundle\Entity\Travel:
properties:
...
destination:
...
- Length:
max: 100
maxMessage: ...
我现在想要的是我只是依赖于 .orm.yml 文件,所以我只需要更改那里的值。
如何根据Travel.orm.yml 中的值设置validation.yml 中的值?
【问题讨论】:
标签: php validation symfony orm