NPv.Results
0.0.1
technical renaming to avoid namespace conflicts
dotnet add package NPv.Results --version 0.0.1
NuGet\Install-Package NPv.Results -Version 0.0.1
<PackageReference Include="NPv.Results" Version="0.0.1" />
<PackageVersion Include="NPv.Results" Version="0.0.1" />
<PackageReference Include="NPv.Results" />
paket add NPv.Results --version 0.0.1
#r "nuget: NPv.Results, 0.0.1"
#:package NPv.Results@0.0.1
#addin nuget:?package=NPv.Results&version=0.0.1
#tool nuget:?package=NPv.Results&version=0.0.1
NPv.Results
Minimal Result pattern implementation for .NET.
A lightweight alternative to exceptions for expected business and validation errors.
Features
- ✅
Result(success/failure without value) - ✅
Result<T>(success/failure with value) - ✅ Multiple errors support (
Result.Failure(params Error[])) - ✅ Strongly typed
Errorrecords with code and property name - ✅ Implicit conversions for cleaner syntax (
T → Result<T>,Error → Result<T>) - ✅ Works with validation and business rules
Example
Defining reusable errors
It’s possible to place error catalogs (e.g. DbErrors) into a shared domain library such as NPv.Domain.Abstractions:
public static class DbErrors
{
public static readonly Error EntityNotFound =
new("DbErrors.EntityNotFound", "EntityId");
public static readonly Error EntityAlreadyExists =
new("DbErrors.EntityAlreadyExists", "EntityId");
}
Returning results from commands
public async Task<Result<User>> CreateUserAsync(string email)
{
if (string.IsNullOrWhiteSpace(email))
return Result<User>.Failure(new Error("Validation.Required", "Email"));
if (await _db.Users.AnyAsync(u => u.Email == email))
return Result<User>.Failure(DbErrors.EntityAlreadyExists);
var user = new User { Email = email };
_db.Users.Add(user);
return Result<User>.Success(user);
}
🚀 Author's Note
This library grew out of my long-standing personal interest in structuring and publishing open source packages. Over time, I’ve revisited and refined earlier internal utilities and ideas, giving them a more consistent shape and preparing them for wider reuse. Along the way, I’ve also taken the opportunity to explore how open source distribution and licensing work in the .NET ecosystem.
It’s a small step toward something I’ve always wanted to try — sharing practical, minimal tools that reflect years of learning, experimentation, and refinement.
Hopefully, someone finds it useful.
Nikolai 😛
⚖️ License
MIT — you are free to use this in commercial and open-source software.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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 was computed. 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. |
-
net9.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 |
|---|