Gubbins
A practical C# utility library. Fluent validation, a clean result pattern, readable truth extensions, and more — without the boilerplate.
Why 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.
Quick Start
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.
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);
}
}
Documentation
Explore the library
Every class, method, and extension is documented with signatures, parameter descriptions, and real-world examples.
Models
Core data structures: Result, Result<T>,
Error, MultiDisposable, and the
IValidatable interface.
Validation
Fluent input validation via extension methods for strings, numerics, and any reference type. Auto-captures parameter names.
Truth
Readable boolean extension methods for collections and numeric values. Replace verbose null checks with expressive intent.
Conversion
Helper extension methods for converting Gubbins models — such as
formatting collections of Error objects into readable strings.