数值字段的 Symfony Collection 约束
确保我的数组包含键 ['extension_attributes']['shipping_assignments'][0]['shipping'] 我想使用以下集合约束验证
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\Mapping\Loader\AbstractLoader::newConstraint():参数 #1 ($name) 必须是字符串类型,给定 int,在 /var/www/ht 中调用
ml/vendor/cleverage/process-bundle/Validator/ConstraintLoader.php 第 44 行
集合约束中第 44 行字段选项无法接受数字键
To make sure my array contains keys ['extension_attributes']['shipping_assignments'][0]['shipping']
I want to use the following Collection constraint validation
Collection:
allowExtraFields: true
fields:
extension_attributes:
- Collection:
allowExtraFields: true
fields:
shipping_assignments:
- Collection:
allowExtraFields: true
fields:
0:
- Collection:
allowExtraFields: true
fields:
shipping: ~
But i have on error on validation because i use the numeric key 0
Symfony\Component\Validator\Mapping\Loader\AbstractLoader::newConstraint(): Argument #1 ($name) must be of type string, int given, called in /var/www/ht
ml/vendor/cleverage/process-bundle/Validator/ConstraintLoader.php on line 44
fields option in Collection constraint cannot accept numeric key
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新
错误是由于约束加载器造成的
如果我使用 php 而不是 yaml 进行约束定义,它可以工作
,
不能工作
Update
Error is due to the constraint loader
if i use php and not yaml for constraint definition it works
Work
Not work