Hyperbee.Pipeline.Validation 3.0.0

dotnet add package Hyperbee.Pipeline.Validation --version 3.0.0
                    
NuGet\Install-Package Hyperbee.Pipeline.Validation -Version 3.0.0
                    
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="Hyperbee.Pipeline.Validation" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hyperbee.Pipeline.Validation" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Hyperbee.Pipeline.Validation" />
                    
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 Hyperbee.Pipeline.Validation --version 3.0.0
                    
#r "nuget: Hyperbee.Pipeline.Validation, 3.0.0"
                    
#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 Hyperbee.Pipeline.Validation@3.0.0
                    
#: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=Hyperbee.Pipeline.Validation&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Hyperbee.Pipeline.Validation&version=3.0.0
                    
Install as a Cake Tool

Hyperbee.Pipeline.Validation

The Hyperbee.Pipeline.Validation library provides base validation implementations and pipeline extensions for Hyperbee.Pipeline. This package is framework-agnostic and works with any validation framework that provides an IValidator<T> adapter.

Features

  • Base Implementations: Concrete ValidationFailure and ValidationResult classes implementing the abstractions
  • Pipeline Extensions: ValidateAsync, IfValidAsync, ValidateAndCancelOnFailureAsync for declarative validation
  • Context Extensions: Methods to store, retrieve, and throw on validation results from pipeline contexts
  • Domain Failure Types: ApplicationValidationFailure, NotFoundValidationFailure, UnauthorizedValidationFailure, ForbiddenValidationFailure
  • Exception Handling: Middleware to map exceptions to validation failures

When to Use This Package

  • Custom Validator Implementation: Building validators without depending on a specific framework
  • Framework-Agnostic Libraries: Creating reusable components that support validation
  • Multiple Validation Frameworks: Using different validators for different scenarios

Basic Usage

Using a Custom Validator

public class EmailValidator : IValidator<EmailAddress>
{
    public async Task<IValidationResult> ValidateAsync(
        EmailAddress instance,
        CancellationToken cancellationToken = default)
    {
        var failures = new List<IValidationFailure>();

        if (string.IsNullOrEmpty(instance.Address))
        {
            failures.Add(new ValidationFailure(
                nameof(instance.Address),
                "Email address is required"));
        }

        return new ValidationResult(failures);
    }

    public Task<IValidationResult> ValidateAsync(
        EmailAddress instance,
        Action<IValidationContext> configure,
        CancellationToken cancellationToken = default)
    {
        return ValidateAsync(instance, cancellationToken);
    }
}

// Register validator
services.AddSingleton<IValidator<EmailAddress>, EmailValidator>();
services.AddSingleton<IValidatorProvider, CustomValidatorProvider>();

// Use in pipeline
var pipeline = PipelineBuilder
    .Start<EmailAddress>()
    .ValidateAsync()
    .Pipe((context, email) => SendEmail(email))
    .Build();

Validation in Pipeline

var pipeline = PipelineBuilder
    .Create<CreateUserInput, User>()
    .ValidateAsync()
    .Pipe((context, input) => CreateUser(input));

Conditional Execution on Validation

var pipeline = PipelineBuilder
    .Create<Order, Order>()
    .ValidateAsync()
    .IfValidAsync(builder => builder
        .PipeAsync(async (ctx, order) => await SaveOrderAsync(order))
    )
    .Build();

Checking Validation Results

var result = await pipeline(context, input);

if (!context.IsValid())
{
    foreach (var error in context.ValidationFailures())
    {
        Console.WriteLine($"{error.PropertyName}: {error.ErrorMessage}");
    }
}

Throwing on Validation Failures

ThrowIfInvalid is the validation counterpart to ThrowIfError — use both when consuming a command outside of HTTP:

var commandResult = await command.ExecuteAsync(input);

commandResult.Context.ThrowIfError();
commandResult.Context.ThrowIfInvalid(); // throws PipelineValidationException carrying the IValidationResult

return commandResult.Result;

Exception Handling Middleware

var pipeline = PipelineFactory
    .Start<string>()
    .WithExceptionHandling(config => config
        .AddException<InvalidOperationException>(errorcode: 1001)
        .AddException<TimeoutException>(errorcode: 1002)
    )
    .Pipe((ctx, arg) => $"hello {arg}")
    .Build();

Domain-Specific Validation Failures

// Not found
context.SetValidationResult(
    new NotFoundValidationFailure("UserId", "User not found"),
    ValidationAction.CancelAfter);

// Unauthorized
context.SetValidationResult(
    new UnauthorizedValidationFailure("", "Authentication required"),
    ValidationAction.CancelAfter);

// Forbidden
context.SetValidationResult(
    new ForbiddenValidationFailure("", "Insufficient permissions"),
    ValidationAction.CancelAfter);

Dependency Injection

// Register your validator provider
services.AddSingleton<IValidatorProvider, YourValidatorProvider>();

// Register pipelines
services.AddPipeline(includeAllServices: true);
  • Hyperbee.Pipeline.Validation.FluentValidation - FluentValidation adapter (most common use case)

For Most Users

If you're using FluentValidation, reference Hyperbee.Pipeline.Validation.FluentValidation instead. This package is primarily for:

  • Custom validator implementations
  • Framework-agnostic libraries
  • Advanced scenarios requiring multiple validation frameworks

Target frameworks

net11.0, net10.0, netstandard2.1. A net8.0 or net9.0 project resolves the netstandard2.1 asset; see the repository README.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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.  net11.0 is compatible. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Hyperbee.Pipeline.Validation:

Package Downloads
Hyperbee.Pipeline.Validation.FluentValidation

FluentValidation integration for Hyperbee.Pipeline async pipelines

Hyperbee.Pipeline.AspNetCore

ASP.NET Core integration for Hyperbee.Pipeline with command result mapping and validation

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 185 11/28/2026
2.16.1 162 11/26/2026
2.16.0 163 11/26/2026
2.15.0 8,138 7/15/2026
2.14.0 2,845 6/8/2026
2.13.0 1,034 5/19/2026
2.12.0 1,459 4/12/2026
2.11.1 1,954 3/26/2026
2.10.1-alpha-gc6f6d9837f 188 3/25/2026
2.9.1 2,707 3/19/2026
2.9.0 187 3/19/2026
2.8.2 230 3/16/2026
2.7.0 2,795 2/28/2026
2.6.0 197 2/28/2026
2.5.0 210 2/28/2026
2.4.0 215 2/27/2026
2.3.3 4,543 2/24/2026
2.3.2 613 2/18/2026
2.3.1 207 2/18/2026
2.3.0 207 2/17/2026