![]() |
VOOZH | about |
dotnet add package Yaver.Result --version 2.1.0
NuGet\Install-Package Yaver.Result -Version 2.1.0
<PackageReference Include="Yaver.Result" Version="2.1.0" />
<PackageVersion Include="Yaver.Result" Version="2.1.0" />Directory.Packages.props
<PackageReference Include="Yaver.Result" />Project file
paket add Yaver.Result --version 2.1.0
#r "nuget: Yaver.Result, 2.1.0"
#:package Yaver.Result@2.1.0
#addin nuget:?package=Yaver.Result&version=2.1.0Install as a Cake Addin
#tool nuget:?package=Yaver.Result&version=2.1.0Install as a Cake Tool
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.
ValidationError details.PagedResult<T> and PagedInfo.Yaver.Result provides several result types to cover different scenarios:
T on success.PagedInfo).Ok, Error, Forbidden, Unauthorized, Invalid, NotFound, Conflict, CriticalError, Unavailable).Yaver.Result is designed to help map operation results to appropriate HTTP response codes in web APIs:
ResultStatus.Ok): Maps to HTTP 200 OK or 201 Created, depending on the operation.ResultStatus.Error): Typically maps to HTTP 400/500 depending on context.ResultStatus.Invalid): Maps to HTTP 422 Unprocessable Entity for validation failures.ResultStatus.Forbidden): Maps to HTTP 403 Forbidden.ResultStatus.Unauthorized): Maps to HTTP 401 Unauthorized.ResultStatus.NotFound): Maps to HTTP 404 Not Found.ResultStatus.Conflict): Maps to HTTP 409 Conflict.ResultStatus.Unavailable): Maps to HTTP 503 Service Unavailable.You can use the ResultToResponse utility to convert result objects to HTTP responses in your controllers.
The library includes MessagePack support for result envelopes with an AOT-safe resolver strategy.
WithYaverResultResolver<T>() to include result envelope formatters for your payload type.Result, Result<T>, PagedResult<T>, and ValidationError.Result/ — Core result types, extensions, and validation utilities.Yaver.Result.csproj — Project file for the library.Result, PagedResult, ValidationError) in your application logic.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.Error("An error occurred.");
return Result.Success();
}
using MessagePack;
using MessagePack.Resolvers;
using Yaver.Result;
var options = MessagePackSerializerOptions.Standard
.WithResolver(StandardResolver.Instance)
.WithYaverResultResolver<MyDto>();
var serialized = MessagePackSerializer.Serialize(Result.Success(new MyDto()), options);
var deserialized = MessagePackSerializer.Deserialize<Result<MyDto>>(serialized, options);
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.