PipeException 1.0.0

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

PipeException

<p align="center"> <img src="Logo.png" alt="PipeException Logo" width="128" /> </p>

NuGet CI License: MIT

A fluent validation and guard clause library for .NET using pipe operators and C# extensions.

Features

  • Pipe Operator Validation: Use the | operator for inline validation
  • Fluent Chaining: Chain multiple validations together seamlessly
  • Custom Exception Types: Choose which exception to throw after validation
  • Built-in Validators: Common validators for strings, collections, nullables, and numeric types
  • Modern C# Syntax: Leverages C# extension methods for clean, readable code

Requirements

  • .NET 10.0 or later

Installation

dotnet add package PipeException

Quick Start

Basic Validation

using PipeException;

// Throws ArgumentException if condition is false
int positiveNumber = value | (x => x > 0);

// With custom error message
int rangedValue = value | (x => x is > 0 and < 100, "Value must be between 0 and 100");

Chained Validations

// Chain multiple conditions
int validatedValue = value
    | (x => x > 0)
    | (x => x < 100)
    | (x => x % 2 == 0);

Choose Exception Type

// Use ValidationResult for deferred exception selection
var result = value | (x => x >= 0);

// Throw specific exception types
result.OrThrowNull("paramName");           // ArgumentNullException
result.OrThrowInvalidOperation();          // InvalidOperationException
result.OrThrow<CustomException>();         // Custom exception
result.OrThrow(() => new MyException());   // Exception factory

Built-in Validators

// String validation
string name = input.EnsureNotNullOrEmpty();
string trimmed = input.EnsureNotNullOrWhiteSpace();
string sized = input.EnsureMinLength(3).EnsureMaxLength(50);

// Numeric validation
int positive = number | Validate.Positive;
int nonNegative = number | Validate.NonNegative;
int ranged = number | Validate.InRange(1, 100);

// Collection validation
var items = list.EnsureNotEmpty();
var sized = list.EnsureMinCount(1).EnsureMaxCount(10);

// Nullable validation
var notNull = nullableValue.EnsureNotNull();

Building from Source

# Build
./build.sh compile    # Linux/macOS
./build.cmd compile   # Windows

# Test
./build.sh test

# Pack
./build.sh pack

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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.
  • net10.0

    • No dependencies.

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.0.0 151 11/29/2025