Browse Source

Expose the `validator` service itself.

Resolve #17596
pull/17672/head
maliming 2 years ago
parent
commit
b5afc77309
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 1
      framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/AbpFluentValidationConventionalRegistrar.cs
  2. 11
      framework/test/Volo.Abp.FluentValidation.Tests/Volo/Abp/FluentValidation/ApplicationService_FluentValidation_Tests.cs

1
framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/AbpFluentValidationConventionalRegistrar.cs

@ -24,6 +24,7 @@ public class AbpFluentValidationConventionalRegistrar : DefaultConventionalRegis
{
return new List<Type>()
{
type,
typeof(IValidator<>).MakeGenericType(GetFirstGenericArgumentOrNull(type, 1)!)
};
}

11
framework/test/Volo.Abp.FluentValidation.Tests/Volo/Abp/FluentValidation/ApplicationService_FluentValidation_Tests.cs

@ -103,6 +103,17 @@ public class ApplicationService_FluentValidation_Tests : AbpIntegratedTest<Appli
output.ShouldBe("444");
}
[Fact]
public void Should_Add_Validators_To_DI()
{
var validator = ServiceProvider.GetService<IValidator<MyMethodInput>>();
validator.GetType().ShouldBe(typeof(MyMethodInputValidator));
validator = ServiceProvider.GetService<MyMethodInputValidator>();
validator.GetType().ShouldBe(typeof(MyMethodInputValidator));
}
[DependsOn(typeof(AbpAutofacModule))]
[DependsOn(typeof(AbpFluentValidationModule))]
public class TestModule : AbpModule

Loading…
Cancel
Save