I was implementing fluent validation in .NET 8 application and got warning that AddFluentValidation is obsolete.

Solution

Instead of below


builder.Services.AddValidatorsFromAssemblyContaining<FlightBookingRequestValidator>();

we have to use below in the Program.cs file

builder.Services.AddFluentValidationAutoValidation()
                .AddFluentValidationClientsideAdapters();
builder.Services.AddValidatorsFromAssemblyContaining<UserprofileValidator>();

we need to replace AddValidatorsFromAssemblyContaining with

.AddFluentValidationAutoValidation()
.AddFluentValidationClientsideAdapters();

Leave a Reply

Your email address will not be published. Required fields are marked *