Skip to content

Commit

Permalink
improve and clarify the validator registration documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdgun committed Dec 4, 2024
1 parent 21c66e4 commit f13fc11
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<IValidator<User>, UserValidator>();
```

#### Automatic registration

Automatically register all validators from the assembly containing your UserValidator:

```
services.AddValidatorsFromAssemblyContaining<UserValidator>();
```

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)

Expand Down

0 comments on commit f13fc11

Please sign in to comment.