Qowaiv.Validation.Guarding 2.2.0

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

Qowaiv Validation Guarding

Fluent pre-condition guards for domain logic. Uses the .Must() extension method to create guard expressions that return Result<T> to communicate the outcome.

Must

The .Must() extension creates a Must<TSubject> guard builder on any object.

Be / NotBe

Guard that a condition is true or false:

Result<Game> result = game.Must().Be(
    game.Phase == GamePhase.Started,
    "Game must be started");

Result<Game> result = game.Must().NotBe(
    game.Phase == GamePhase.Finished,
    "Game must not be finished");

Returns a valid Result<Game> if the condition is met, otherwise an invalid result with the specified error message.

Exist

Guard that a related entity exists by ID. Useful in command handlers:

Result<PlaceOrder> result = command.Must().Exist(
    command.CustomerId,
    (cmd, id) => customerRepository.Find(id));

Returns a valid result if the entity is found, otherwise an invalid result with an EntityNotFound message.

You can also provide a custom error message:

Result<PlaceOrder> result = command.Must().Exist(
    command.CustomerId,
    (cmd, id) => customerRepository.Find(id),
    ValidationMessage.Error("Customer not found"));

Custom guards

Extend Must<TSubject> with custom extension methods for domain-specific guarding:

public static class MustOrderExtensions
{
    public static Result<Order> MustBePlaced(this Order order)
        => order.Must().Be(
            order.Status == OrderStatus.Placed,
            "Order must be in Placed status");
}
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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 Qowaiv.Validation.Guarding:

Package Downloads
Qowaiv.DomainModel

Qowaiv implements common, universal domain objects. These types form the base of your domain model.

Qowaiv.DomainModel.TestTools

Qowaiv implements common, universal domain objects. These types form the base of your domain model.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 959 9/30/2026
2.1.0 30,736 5/21/2026
2.0.0 11,994 1/19/2026
1.0.0 67,638 11/19/2024
0.3.1 33,247 5/31/2023
0.3.0 403 3/7/2023
0.2.1 23,095 4/13/2022
0.1.2 24,046 9/23/2021

v2.2.0
- Update dependencies.
v2.1.0
- Add notnull constraint to Result.For<T>().
v2.0.0
- Add .NET 10.0 target.
- Drop .NET9.0 targets. (BREAKING)
v1.0.0
- Add .NET 9.0 target.
- Drop .NET 5.0, NET6.0, NET7.0 targets. (BREAKING)
V0.3.1
- Fixed lacking nullable annotations. #67
v0.3.0
- Support .NET 7.0. #62
v0.2.1
- Nullable anotations. #48
v0.1.2
- Initial version
- Introduction of the Must() guarding mechanism #41.