Skip to content

improve and clarify the validator registration documentation #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading