Izi.FluentData.Validation.DependencyInjectionExtensions 1.1.5

dotnet add package Izi.FluentData.Validation.DependencyInjectionExtensions --version 1.1.5
                    
NuGet\Install-Package Izi.FluentData.Validation.DependencyInjectionExtensions -Version 1.1.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Izi.FluentData.Validation.DependencyInjectionExtensions" Version="1.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Izi.FluentData.Validation.DependencyInjectionExtensions" Version="1.1.5" />
                    
Directory.Packages.props
<PackageReference Include="Izi.FluentData.Validation.DependencyInjectionExtensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Izi.FluentData.Validation.DependencyInjectionExtensions --version 1.1.5
                    
#r "nuget: Izi.FluentData.Validation.DependencyInjectionExtensions, 1.1.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Izi.FluentData.Validation.DependencyInjectionExtensions@1.1.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Izi.FluentData.Validation.DependencyInjectionExtensions&version=1.1.5
                    
Install as a Cake Addin
#tool nuget:?package=Izi.FluentData.Validation.DependencyInjectionExtensions&version=1.1.5
                    
Install as a Cake Tool

Izi.FluentData.Validation.DependencyInjectionExtensions

Microsoft.Extensions.DependencyInjection registration helpers for Izi.FluentData.Validation. Kept in a separate package so the core library stays dependency-free — reference this only when you want container wiring.

dotnet add package Izi.FluentData.Validation.DependencyInjectionExtensions
  • Target framework: net10.0
  • Dependencies: Microsoft.Extensions.DependencyInjection.Abstractions (+ the core Izi.FluentData.Validation)
  • Namespace: helpers live in Microsoft.Extensions.DependencyInjection, so they surface wherever IServiceCollection is in scope.

Usage

using Microsoft.Extensions.DependencyInjection;

// register a validator type (singleton by default)
services.AddValidator<CustomerValidator>();
services.AddValidator<CustomerValidator>(ServiceLifetime.Scoped);

// register a pre-built instance or a factory
services.AddValidator<Customer>(new CustomerValidator());
services.AddValidator<Customer>(sp => new CustomerValidator(/* deps */));

// scan one or more assemblies for every IValidator<T> implementation
services.AddValidators(ServiceLifetime.Singleton, typeof(CustomerValidator).Assembly);

Then inject the interface wherever you need it:

public sealed class CustomerService(IValidator<Customer> validator)
{
    public ValueTask<IReadOnlyList<string>> CheckAsync(Customer customer)
        => validator.ValidateAsync(customer);
}

How registration works

AddValidator<T>() registers the concrete type once, then forwards every IValidator<T> interface the type implements to that single registration:

services.AddValidator<CustomerValidator>();

   CustomerValidator           ──▶  (one registration, the chosen lifetime)
   IValidator<Customer>        ──▶  sp => sp.GetRequiredService<CustomerValidator>()

Two consequences worth knowing:

  • Resolving the interface and the concrete type returns the same instance. A singleton is therefore never built twice, even though it is registered under two service types.
  • One type can serve several IValidator<T>. If a class implements IValidator<A> and IValidator<B>, both interfaces resolve to the same shared instance.

AddValidators(...) applies the same logic to every non-abstract, non-generic IValidator<T> implementation it discovers in the supplied assemblies. Passing a type that does not implement IValidator<T> throws ArgumentException.


Which lifetime?

Singleton (the default) is recommended. A validator builds its rule set once in the constructor and is stateless and thread-safe afterward, so a single shared instance avoids repeating that setup and is safe under concurrency.

Drop to Scoped or Transient only when the validator itself depends on a shorter-lived service (e.g. a DbContext). Match its lifetime to its shortest-lived dependency to avoid a captive-dependency bug.


Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.5 109 7/27/2026
1.1.4 108 7/27/2026
1.1.3 112 7/24/2026
1.1.2 110 7/24/2026
1.1.1 122 7/24/2026
1.1.0 116 7/24/2026
1.0.4 114 6/30/2026
1.0.3 119 6/30/2026
1.0.2 121 6/18/2026
1.0.1 116 6/17/2026
1.0.0 227 6/17/2026