小编sti*_*ian的帖子

如何在FluentValidation中从多个程序集中注册验证器?

我在多个程序集中包含FluentValidators。在FluentValidation的早期版本中,我可以这样注册:

services.AddMvc()
  .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<ClassInAssemblyOne>())
  .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<ClassInAssemblyTwo>());
Run Code Online (Sandbox Code Playgroud)

但是,这现在导致以下错误:

Exception thrown: 'System.InvalidOperationException' in System.Linq.dll
An exception of type 'System.InvalidOperationException' occurred in System.Linq.dll but was not handled in user code
Sequence contains more than one matching element
Run Code Online (Sandbox Code Playgroud)

不再允许了吗?如果没有,执行此操作的正确方法是什么?

fluentvalidation

3
推荐指数
1
解决办法
1159
查看次数

标签 统计

fluentvalidation ×1