From f13fc113ecdf476fd8abdde9478551ec416515c2 Mon Sep 17 00:00:00 2001 From: Mauro van der Gun Date: Wed, 4 Dec 2024 17:13:13 -0400 Subject: [PATCH] improve and clarify the validator registration documentation --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ac5fc5..b8bcd03 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,27 @@ This library re-introduces this functionality for MVC controllers and introduces ## Installation -Register your validators with the Microsoft DI service container, for instructions on setting that up please see https://docs.fluentvalidation.net/en/latest/di.html. +### Validator registration + +To enable this library to automatically resolve and invoke validators for your models, you must register your validators with the Dependency Injection (DI) service container. + +#### Manual registration + +Manually register your validator with the service container: + +``` +services.AddScoped, UserValidator>(); +``` + +#### Automatic registration + +Automatically register all validators from the assembly containing your UserValidator: + +``` +services.AddValidatorsFromAssemblyContaining(); +``` + +For more instructions on setting that up please see https://docs.fluentvalidation.net/en/latest/di.html. ### MVC controllers [![NuGet](https://img.shields.io/nuget/v/SharpGrip.FluentValidation.AutoValidation.Mvc)](https://www.nuget.org/packages/SharpGrip.FluentValidation.AutoValidation.Mvc)