-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
Background
The AddFluentValidation method currently enables both auto-validation and clientside integration. This method is being deprecated in favour of two replacements to allow finer control of which features are enabled:
AddFluentValidationAutoValidationAddFluentValidationClientsideAdapters
Migration
If you were previously calling any of the following methods:
services.AddMvc().AddFluentValidation()services.AddMvcCore().AddFluentValidation()services.AddFluentValidation()
...you should now instead call:
services.AddFluentValidationAutoValidation();
services.AddFluentValidationClientsideAdapters()If you were previously using one of the service registration methods as part of your call to AddFluentValidation then you will need to call the corresponding AddValidators… method too:
// Before
services.AddFluentValidation(options => {
options.RegisterValidatorsFromAssemblyContaining<MyValidator>();
});
// After migration:
services.AddFluentValidationAutoValidation();
services.AddFluentValidationClientsideAdapters();
services.AddValidatorsFromAssemblyContaining<MyValidator>();If you were previously disabling either auto-validation or clientside validation, now you should just remove the feature you no longer need.
// Before: Enabling auto-validation and disabling clientside validation
services.AddFluentValidation(config =>
{
config.ConfigureClientsideValidation(enabled: false);
});
// After: Enabling auto-validation only
services.AddFluentValidationAutoValidation();// Before: Disabling auto-validation and leaving clientside validation enabled:
services.AddFluentValidation(config =>
{
config.AutomaticValidationEnabled = false;
});
// After: Enabling client validation only:
services.AddFluentValidationClientsideAdapters();