Skip to content

ghanavat/ResultPattern

Repository files navigation

Ghanavats.ResultPattern

A Robust and Flexible Result Handling Framework for Modern Applications

Overview

Ghanavats.ResultPattern is a small/simple, unambitious framework designed to bring consistency and flexibility to result handling in your applications. Whether you need to return simple success/error outcomes or handle complex validation scenarios, this solution provides the tools you need to implement robust result patterns effortlessly.

The idea behind this was to learn the Result Pattern by implementing it in a good way. The plan was not and is not to get all developers, worldwide, to adopt it. Instead, to teach myself, and maybe if I am lucky, to show you what it may look like.

The solution includes

  1. Ghanavats.ResultPattern

    A fully-featured implementation of the result pattern, offering generic results for any type, extensions for FluentAssertions, and comprehensive validation support. By leveraging this solution, developers can simplify their workflows, reduce boilerplate code, and establish a consistent approach to handling results across projects.

By leveraging this solution, developers can simplify their workflows, reduce boilerplate code, and establish a consistent approach to handling results across projects.

Features

  • Generic Result Handling: Return results for any type, enabling flexibility and versatility in application workflows.
  • Simple Success/Error Results: Simplify scenarios where only success or error outcomes are needed.
  • FluentValidation Support: Integrate seamlessly with FluentValidation to handle validation results effectively.
  • Extensibility: Built as a flexible framework, it allows developers to design and implement their own variations of the result pattern to suit their needs.
  • Rich Error Representation: Utilise ProblemDetails and ValidationProblemDetails for structured error information (RFC 9457).
  • Map results to HTTP responses in ASP.NET Core applications.
  • Aggregate multiple results into a single object for comprehensive outcome representation.

Getting Started

  1. Install the Package:

    Add the NuGet package to your project:

    dotnet add package Ghanavats.ResultPattern
    
  2. Define Your Results: Use the Result classes to define your success, error, invalid or not-found outcomes consistently across your application.

  3. Integrate Validation: Leverage the FluentValidation ValidationResult class to handle validation failures gracefully and with clarity.

Ongoing Development

Ghanavats.ResultPattern is an actively maintained and evolving library. We are committed to improving its capabilities and adding features to enhance its value for developers. Feedback and suggestions from the community are always welcome as we strive to make this library even more robust and versatile.

Contributing

We welcome contributions to improve Ghanavats.ResultPattern! If you have ideas for new features or enhancements, feel free to submit an issue or a pull request.

Learn about what Ghanavats Result Pattern offers and how to use its current features:

Ghanavats Result Pattern Documentation

About

Simple implementation of Result Pattern

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages