Fox.ValidationKit.ResultKit 1.0.0

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

Fox.ValidationKit.ResultKit

ResultKit integration for Fox.ValidationKit

Fox.ValidationKit.ResultKit provides seamless integration between Fox.ValidationKit and Fox.ResultKit, enabling Railway Oriented Programming patterns for validation workflows.

Installation

dotnet add package Fox.ValidationKit.ResultKit

NuGet Package Manager:

Install-Package Fox.ValidationKit.ResultKit

PackageReference:

<PackageReference Include="Fox.ValidationKit.ResultKit" Version="1.0.0" />

Prerequisites

This package requires:

  • Fox.ValidationKit 1.0.0 or later
  • Fox.ResultKit 1.2.0 or later

Quick Start

ValidateAsResult

Convert ValidationResult to Result:

using Fox.ValidationKit.ResultKit;

var validator = new UserValidator();
var result = validator.ValidateAsResult(user);

return result.Match(
    onSuccess: () => Ok("User validated successfully"),
    onFailure: error => BadRequest(error)
);

ValidateAsResultValue

Return the validated value with Result<T>:

var result = validator.ValidateAsResultValue(user);

return result.Match(
    onSuccess: validUser => Ok(validUser),
    onFailure: error => BadRequest(error)
);

ValidateAsErrorsResult

Get individual validation errors as separate Results:

var errorsResult = validator.ValidateAsErrorsResult(user);

if (!errorsResult.IsSuccess)
{
    foreach (var error in errorsResult.Errors)
    {
        Console.WriteLine($"- {error.Error}");
    }
}

Features

  • ValidateAsResult - Convert ValidationResult to Result
  • ValidateAsResultValue - Return validated value with Result<T>
  • ValidateAsErrorsResult - Get individual errors as ErrorsResult
  • Async Support - All methods have async variants
  • Error Aggregation - Automatic error message aggregation with FVK codes
  • Railway Oriented Programming - Functional error handling patterns

API Reference

Extension Methods for Validator<T>

// Synchronous
Result ValidateAsResult<T>(this Validator<T> validator, T instance);
Result<T> ValidateAsResultValue<T>(this Validator<T> validator, T instance);
ErrorsResult ValidateAsErrorsResult<T>(this Validator<T> validator, T instance);

// Asynchronous
Task<Result> ValidateAsResultAsync<T>(this Validator<T> validator, T instance, CancellationToken cancellationToken = default);
Task<Result<T>> ValidateAsResultValueAsync<T>(this Validator<T> validator, T instance, CancellationToken cancellationToken = default);
Task<ErrorsResult> ValidateAsErrorsResultAsync<T>(this Validator<T> validator, T instance, CancellationToken cancellationToken = default);

Extension Methods for ValidationResult

Result ToResult(this ValidationResult validationResult);
Result<T> ToResult<T>(this ValidationResult validationResult, T value);
ErrorsResult ToErrorsResult(this ValidationResult validationResult);

Example: ASP.NET Core Integration

[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
    private readonly UserValidator validator;

    public UsersController(UserValidator validator)
    {
        this.validator = validator;
    }

    [HttpPost]
    public IActionResult CreateUser([FromBody] User user)
    {
        var result = validator.ValidateAsResult(user);

        return result.Match(
            onSuccess: () => CreatedAtAction(nameof(GetUser), new { id = user.Id }, user),
            onFailure: error => BadRequest(new { Error = error })
        );
    }

    [HttpPut("{id}")]
    public IActionResult UpdateUser(int id, [FromBody] User user)
    {
        var result = validator.ValidateAsResultValue(user);

        return result.Match(
            onSuccess: validUser => Ok(validUser),
            onFailure: error => BadRequest(new { Error = error })
        );
    }

    [HttpPost("batch")]
    public IActionResult CreateUsers([FromBody] List<User> users)
    {
        var errorsResult = ErrorsResult.Success();

        foreach (var user in users)
        {
            var validationResult = validator.ValidateAsErrorsResult(user);
            errorsResult = errorsResult.Combine(validationResult);
        }

        if (!errorsResult.IsSuccess)
        {
            return BadRequest(new
            {
                Errors = errorsResult.Errors.Select(e => e.Error)
            });
        }

        return Ok("All users validated successfully");
    }
}

Example: Async Validation

public class UserValidator : Validator<User>
{
    private readonly IUserRepository repository;

    public UserValidator(IUserRepository repository)
    {
        this.repository = repository;

        RuleFor(x => x.Email)
            .NotEmpty()
            .CustomAsync(async (user, email, cancellationToken) =>
            {
                var exists = await repository.EmailExistsAsync(email, cancellationToken);
                return !exists;
            }, "Email is already registered");
    }
}

// Usage
var result = await validator.ValidateAsResultAsync(user, cancellationToken);

return result.Match(
    onSuccess: () => Ok("User validated"),
    onFailure: error => BadRequest(error)
);

Documentation

Full documentation available at:

License

Fox.ValidationKit.ResultKit is licensed under the MIT License.

Copyright (c) 2026 Karoly Akacz

Author

Karoly Akacz

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 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 116 2/22/2026