FailOr 1.1.0

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

FailOr

NuGet Version NuGet Downloads CI Targets License

FailOr is the core package for explicit success-and-failure flows in .NET. It gives you a small result type, a failure union, and composable helpers for mapping, matching, chaining, and aggregation.

Install

dotnet add package FailOr

Core Surface

  • FailOr<T> represents either a success value or one-or-more failures.
  • Failures is the abstract failure union carried by failed results.
  • Failure is the public factory surface for Failures.General, Failures.Validation, and Failures.Exceptional.
  • Chaining and observation helpers include Then, ThenAsync, ThenEnsure, FailWhen, ThenDo, IfSuccess, IfFail, Match, MatchFirst, Try, Zip, and Combine.

Quick Start

Create success and failure results:

using FailOr;

var success = FailOr.Success(42);
var failure = FailOr.Fail<int>(Failure.General("Input was invalid."));

if (success.IsSuccess)
{
    Console.WriteLine(success.UnsafeUnwrap());
}

if (failure.IsFailure)
{
    Console.WriteLine(failure.Failures[0].Details);
}

Chain success values:

using FailOr;

var result = FailOr.Success(10)
    .Then(value => value + 5)
    .ThenEnsure(value =>
        value >= 0
            ? FailOr.Success(true)
            : FailOr.Fail<bool>(Failure.General("Value must be non-negative.")))
    .Then(value => value * 2);

Handle both outcomes with Match:

using FailOr;

var message = FailOr.Fail<int>(Failure.General("The value could not be produced."))
    .Match(
        success: value => $"Value: {value}",
        failure: failures => failures[0].Details);

Convert thrown exceptions into failures with Try:

using FailOr;

var parsed = FailOr.Success("42")
    .Try(value => int.Parse(value));

Use FailOr.Validations when you want typed, property-selector based validation helpers that build on top of the core package:

dotnet add package FailOr.Validations

Documentation

License

Licensed under the MIT License. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FailOr:

Package Downloads
FailOr.Validations

Typed property-based validation helpers for FailOr with selector normalization and transform pipelines.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 112 3/15/2026
1.0.1 88 3/10/2026
1.0.0 86 3/10/2026