Skip to main content

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

PackageDescriptionWhen to install
Vali-ValidationValidation coreAlways
Vali-Validation.MediatRIntegration with MediatRIf you use MediatR
Vali-Validation.ValiMediatorIntegration with Vali-MediatorIf you use Vali-Mediator
Vali-Validation.AspNetCoreASP.NET Core middleware and filtersIf 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.MediatR and Vali-Validation.ValiMediator in 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

<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.