Yaver.Result
1.0.0
dotnet add package Yaver.Result --version 1.0.0
NuGet\Install-Package Yaver.Result -Version 1.0.0
<PackageReference Include="Yaver.Result" Version="1.0.0" />
<PackageVersion Include="Yaver.Result" Version="1.0.0" />
<PackageReference Include="Yaver.Result" />
paket add Yaver.Result --version 1.0.0
#r "nuget: Yaver.Result, 1.0.0"
#:package Yaver.Result@1.0.0
#addin nuget:?package=Yaver.Result&version=1.0.0
#tool nuget:?package=Yaver.Result&version=1.0.0
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
- Add a reference to the Yaver.Result project in your .NET solution.
- Use the provided result types (e.g.,
Result
,PagedResult
,ValidationError
) in your application logic. - 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 | Versions 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. |
-
net10.0
- FastEndpoints (>= 7.0.1)
- FastEndpoints.Messaging.Core (>= 7.0.1)
- FastEndpoints.Messaging.Remote (>= 7.0.1)
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 |