![]() ![]() ![]() If you are using the more basic FluentValidation or FluentValidation.DependencyInjectionExtensions libraries, then they will not automatically register IValidatorFactory and you will get an error at runtime: "ValidatorFactory is not provided. Problem: I'm using FluentValidation or FluentValidation.DependencyInjectionExtensions instead of FluentValidation.AspNetCore Workaround: Hide dependent validators with internal and use Include to include other validation rules to one "Main" validator. Build() Problem: I cant use several validators of one typeĮxample: You split validator into several small validators but AspNetCore uses only one of them. UseDefaultServiceProvider( options => options. Needed for using scoped services (for example DbContext) in validators Public static IWebHost BuildWebHost( string args) => WebHost. WARNING: Swashbuckle implements minimum and maximim as int so you will loss fraction part of float and double numbers RuleFor( sample => sample. Public class SampleValidator : AbstractValidator ValidatorFactoryType = typeof( HttpContextServiceProviderValidatorFactory) Ĭ. ![]() Optionally set validator factory if you have problems with scope resolve inside validators. RegisterValidatorsFromAssembl圜ontaining() HttpContextServiceProviderValidatorFactory requires access to HttpContext services. public void ConfigureServices( IServiceCollection services) Use this method to add services to the container. This method gets called by the runtime. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |