Installation
Prerequisites
- .NET SDK 7.0, 8.0 or 9.0
- Any compatible IDE: Visual Studio 2022+, Rider, VS Code with C# DevKit
Available Packages
| Package | Description | When to install |
|---|---|---|
Vali-Validation | Validation core | Always |
Vali-Validation.MediatR | Integration with MediatR | If you use MediatR |
Vali-Validation.ValiMediator | Integration with Vali-Mediator | If you use Vali-Mediator |
Vali-Validation.AspNetCore | ASP.NET Core middleware and filters | If you use ASP.NET Core |
Core Package: Vali-Validation
Install the core package in the project where you define validators (usually the Application or API project).
.NET CLI
dotnet add package Vali-Validation
Package Manager Console (Visual Studio)
Install-Package Vali-Validation
PackageReference in .csproj
<ItemGroup>
<PackageReference Include="Vali-Validation" Version="1.0.0" />
</ItemGroup>
The core package has a single transitive dependency: Microsoft.Extensions.DependencyInjection.Abstractions. This means you can use it in class library projects without dragging in the full DI container.
MediatR Integration: Vali-Validation.MediatR
Install this package in addition to the core in the project where you configure MediatR (usually the API or Infrastructure project).
dotnet add package Vali-Validation.MediatR
This package already includes Vali-Validation as a dependency.
Typical Structure with MediatR
MyApp.sln
├── MyApp.Api/ ← Install Vali-Validation.MediatR + MediatR
│ └── Program.cs
├── MyApp.Application/ ← Install Vali-Validation
│ ├── Commands/
│ │ └── CreateOrderCommand.cs
│ └── Validators/
│ └── CreateOrderValidator.cs
└── MyApp.Domain/ ← No validation dependencies
<!-- MyApp.Application.csproj -->
<ItemGroup>
<PackageReference Include="Vali-Validation" Version="1.0.0" />
</ItemGroup>
<!-- MyApp.Api.csproj -->
<ItemGroup>
<PackageReference Include="Vali-Validation.MediatR" Version="1.0.0" />
<PackageReference Include="MediatR" Version="12.0.0" />
<ProjectReference Include="..\MyApp.Application\MyApp.Application.csproj" />
</ItemGroup>
Vali-Mediator Integration: Vali-Validation.ValiMediator
Install this package if you use Vali-Mediator instead of MediatR.
dotnet add package Vali-Validation.ValiMediator
Important: Do not install
Vali-Validation.MediatRandVali-Validation.ValiMediatorin the same project. They are mutually exclusive because they implement the same pipeline behavior for different mediators.
ASP.NET Core Integration: Vali-Validation.AspNetCore
Install this package in the API project.
dotnet add package Vali-Validation.AspNetCore
This package can be used in combination with Vali-Validation.MediatR or Vali-Validation.ValiMediator. It can also be used standalone if you are not using any mediator.
Common Combinations
Minimal API + Vali-Mediator + AspNetCore:
<ItemGroup>
<PackageReference Include="Vali-Validation.ValiMediator" Version="1.0.0" />
<PackageReference Include="Vali-Validation.AspNetCore" Version="1.0.0" />
</ItemGroup>
MVC API + MediatR + AspNetCore:
<ItemGroup>
<PackageReference Include="Vali-Validation.MediatR" Version="1.0.0" />
<PackageReference Include="Vali-Validation.AspNetCore" Version="1.0.0" />
</ItemGroup>
Manual validation only (without mediator):
<ItemGroup>
<PackageReference Include="Vali-Validation" Version="1.0.0" />
<PackageReference Include="Vali-Validation.AspNetCore" Version="1.0.0" />
</ItemGroup>
Verifying the Installation
After installing, build the project to ensure there are no conflicts:
dotnet build
You can verify the namespaces are available with a test file:
using Vali_Validation.Core.Validators;
using Vali_Validation.Core.Results;
// If it compiles, the installation is correct.
public class SampleValidator : AbstractValidator<string>
{
public SampleValidator()
{
RuleFor(x => x).NotEmpty();
}
}
Version Configuration
Fixed version (recommended for production)
<PackageReference Include="Vali-Validation" Version="1.0.0" />
Latest compatible minor version
<PackageReference Include="Vali-Validation" Version="1.*" />
Latest version (development only)
<PackageReference Include="Vali-Validation" Version="*" />
Next Step
With the packages installed, continue with the Quick Start to see a complete working example in minutes.