我正在尝试使用symfony验证器进行样本验证,我的数据数组如下所示:
$data = array("firstname" => "", "lastname" => "", "address" => array("street" => "", "city" => ""));
我的约束数组就像
$valueConstraints = array("firstname" => new NotBlank(array('message' => "Please fill firstname")),
"lastname" => new NotBlank(array('message' => "Please fill lastname")),
"address" => array("street" => new NotBlank(array('message' => "Please fill the street for address field")),
"city" => new NotBlank(array('message' => "Please fill city for address field"))));
但是当我试图建立一个集合时
$collectionConstraint = new Collection($constraints)
抛出约束错误:
The options \"street\", \"city\" do not exist in constraint
街道和城市选项属于地址类别,不知道是否可以使用symfony验证程序以多维数组格式创建约束。 / p>