数字字段的Symfony集合约束



确保我的数组包含键['extension_attributes']['sipping_assignments'][0]['sipping']我想使用以下集合约束验证

Collection:
allowExtraFields: true
fields:
extension_attributes:
-   Collection:
allowExtraFields: true
fields:
shipping_assignments:
-   Collection:
allowExtraFields: true
fields:
0:
-   Collection:
allowExtraFields: true
fields:
shipping: ~                 

但我在验证时有一个错误,因为我使用了数字键0

Symfony\Component\Validator\MMapping\Loader\AbstractLoader::newConstraint((:参数#1($name(必须是字符串类型,给定int,在第44行的/var/www/ht中调用

集合约束中的

字段选项不能接受数字键

更新

错误是由约束加载程序引起的如果我使用php而不是yaml进行约束定义,那么就可以工作

工作

$constraint = new AssertCollection(
[
'fields' => [
0 => [new AssertNotBlank()]
]
]
);

不工作

Collection:
fields:
0:  [NotBlank]

最新更新