Yaver.Result 1.0.0

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

Yaver.Result

Yaver.Result is a .NET library designed to provide a standardized way to handle operation results, validation, and error management in your applications. It offers a set of result types, extension methods, and utilities to simplify the handling of success, failure, and validation scenarios.

Features

Result Types

Yaver.Result provides several result types to cover different scenarios:

  • Result: Represents a basic operation result, indicating success or failure, with optional error messages.
  • Result<T>: A generic result type that carries a value of type T on success.
  • PagedResult<T>: Represents a paged result set, including pagination metadata (PagedInfo).
  • ValidationError: Encapsulates validation error details, such as property name, error message, and severity.
  • Result.Void: Used for operations that do not return a value but still indicate success or failure.
  • ResultStatus: Enum representing the status of a result (e.g., Success, Failure, ValidationError).
  • PagedInfo: Contains pagination information such as page number, page size, and total count.

HTTP Response Code Mapping

Yaver.Result is designed to help map operation results to appropriate HTTP response codes in web APIs:

  • Success (ResultStatus.Success): Maps to HTTP 200 OK or 201 Created, depending on the operation.
  • Failure (ResultStatus.Failure): Maps to HTTP 400 Bad Request for client errors, or 500 Internal Server Error for unexpected failures.
  • ValidationError (ResultStatus.ValidationError): Maps to HTTP 422 Unprocessable Entity, indicating validation issues with the request.

You can use the ResultToResponse utility to convert result objects to HTTP responses in your controllers.

  • Result Types: Easily represent success, failure, and validation results with rich information.
  • Validation Support: Integrate validation errors and severities into your result objects.
  • Paging Support: Built-in support for paged results and pagination metadata.
  • Extension Methods: Fluent APIs for working with results and validation outcomes.

Project Structure

  • Result/ — Core result types, extensions, and validation utilities.
  • Yaver.Result.csproj — Project file for the library.

Getting Started

  1. Add a reference to the Yaver.Result project in your .NET solution.
  2. Use the provided result types (e.g., Result, PagedResult, ValidationError) in your application logic.
  3. Leverage extension methods for fluent result handling and validation integration.

Example Usage

// ...existing code... // Example of mapping a result to an HTTP response in ASP.NET Core:

public IActionResult MyAction()
{
    var result = DoSomething();
    return result.ToResponse(); // Uses ResultToResponse to map to the correct HTTP status code
}
using Yaver.Result;

public Result DoSomething()
{
    if (/* some error condition */)
        return Result.Failure("An error occurred.");
    return Result.Success();
}

License

// ...existing code... This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET 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.

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
1.0.0 220 7/28/2025