使用FluentValidation验证集合

4
我正在尝试做类似于这样的事情:
RuleFor(client => client.PriceCustomization.GroupBy(a=>a.ProductId).Select(a => a.ToList()))
   .SetCollectionValidator(new PriceCustomizationsForProductValidator());

但是我收到了这个错误: 失败: System.InvalidOperationException : 嵌套验证器只能与成员表达式一起使用。
PriceCustomizationsForProductValidator” 是一个用于“PriceCustomization”列表的验证器。
有没有人有任何想法如何解决这个问题?
2个回答

4

0
如果PriceCustomizationsForProductValidator是列表类型的验证器,那么您不需要调用.SetCollectionValidator。相反,您应该只需调用.SetValidator即可。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接