.NET 6+  ·  Apache 2.0

Gubbins

A practical C# utility library. Fluent validation, a clean result pattern, readable truth extensions, and more — without the boilerplate.

$ dotnet add package Gubbins

Reuse, not rewrite

Gubbins handles the repetitive patterns that appear in every C# project, letting you focus on what makes your application unique.

Fluent Validation

Chain validation calls as extension methods directly on values. Parameter names are captured automatically — no nameof() required.

Result Pattern

Communicate success or failure without throwing exceptions for expected outcomes. Carry typed output and structured error details in one object.

Truth Extensions

Replace verbose null-and-count checks with readable boolean expressions like .None() and .IsBetween() on collections and numerics.

Rich Error Model

Attach human-readable descriptions, technical details, and the originating exception to every error — all in a single, composable Error object.

Up and running in minutes

Install the NuGet package, add the relevant using directives, and your values gain new extension methods immediately.

The example on the right shows a typical service method: inputs are validated inline, work is performed, and a typed Result<T> is returned — no custom exception types needed.

Validation docs Result model
using Gubbins.Validation;
using Gubbins.Models;

public Result<User> CreateUser(
    string? name,
    string? email,
    int age)
{
    // Validation — parameter names captured automatically
    name.EnsureNotNullEmptyOrWhitespace();
    email.EnsureNotNullEmptyOrWhitespace();
    age.EnsureBetween(18, 120);

    User user = userRepository.Create(name, email, age);

    return new Result<User>(user);
}

// Checking results
Result<User> result = CreateUser("Alice", "alice@example.com", 30);

if (result.Succeeded)
{
    User user = result.Output!;
    Console.WriteLine($"Created: {user.Name}");
}
else
{
    foreach (Error error in result.Errors)
    {
        Console.WriteLine(error.Description);
    }
}

Explore the library

Every class, method, and extension is documented with signatures, parameter descriptions, and real-world examples.