REslava.Result.FluentValidation 1.50.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package REslava.Result.FluentValidation --version 1.50.0
                    
NuGet\Install-Package REslava.Result.FluentValidation -Version 1.50.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="REslava.Result.FluentValidation" Version="1.50.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="REslava.Result.FluentValidation" Version="1.50.0" />
                    
Directory.Packages.props
<PackageReference Include="REslava.Result.FluentValidation">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 REslava.Result.FluentValidation --version 1.50.0
                    
#r "nuget: REslava.Result.FluentValidation, 1.50.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 REslava.Result.FluentValidation@1.50.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=REslava.Result.FluentValidation&version=1.50.0
                    
Install as a Cake Addin
#tool nuget:?package=REslava.Result.FluentValidation&version=1.50.0
                    
Install as a Cake Tool

REslava.Result.FluentValidation

⚠️ Optional — migration bridge only.

This package is not needed for new projects. REslava.Result already includes full validation natively via [Validate] (DataAnnotations → Result<T>) and the Validation DSL (19 fluent rules). Install this package only if your team already uses FluentValidation validators and wants to keep them while adopting REslava.Result.

FluentValidation bridge for REslava.Result — keep your existing validators, get Result<T> and SmartEndpoints auto-injection for free.

NuGet Downloads License

What It Does

A migration bridge for teams with existing FluentValidation validators who are adopting REslava.Result. Decorate your request type with [FluentValidate] and the generator emits:

  • Validate(IValidator<T> validator) — sync, runs validator.Validate(), returns Result<T>
  • ValidateAsync(IValidator<T> validator, CancellationToken) — async variant

SmartEndpoints auto-injection — when a POST/PUT body parameter is decorated with [FluentValidate], the generated Minimal API lambda automatically adds IValidator<T> as a parameter and emits the validation guard block.

Quick Start

dotnet add package REslava.Result
dotnet add package REslava.Result.SourceGenerators
dotnet add package REslava.Result.FluentValidation   # ← bridge
dotnet add package FluentValidation                  # ← your existing validators
using REslava.Result.FluentValidation;
using FluentValidation;

// 1. Decorate the request type
[FluentValidate]
public record CreateOrderRequest(string CustomerId, decimal Amount);

// 2. Your existing FluentValidation validator — unchanged
public class CreateOrderRequestValidator : AbstractValidator<CreateOrderRequest>
{
    public CreateOrderRequestValidator()
    {
        RuleFor(x => x.CustomerId).NotEmpty();
        RuleFor(x => x.Amount).GreaterThan(0);
    }
}

// 3. Register in DI
builder.Services.AddScoped<IValidator<CreateOrderRequest>, CreateOrderRequestValidator>();

// 4. Manual usage
IValidator<CreateOrderRequest> validator = new CreateOrderRequestValidator();
Result<CreateOrderRequest> result = request.Validate(validator);

// 5. SmartEndpoints — validator auto-injected, no extra wiring needed
[AutoGenerateEndpoints(RoutePrefix = "/api/orders")]
public class OrderService
{
    public async Task<Result<Order>> CreateOrder(CreateOrderRequest req) => ...;
}
// app.MapOrderServiceEndpoints();  ← one line, validator injected automatically

Generated Code

For each type decorated with [FluentValidate]:

// namespace Generated.FluentValidationExtensions
public static class CreateOrderRequestFluentValidationExtensions
{
    public static Result<CreateOrderRequest> Validate(
        this CreateOrderRequest instance,
        IValidator<CreateOrderRequest> validator)
    {
        var result = validator.Validate(instance);
        if (result.IsValid)
            return Result<CreateOrderRequest>.Ok(instance);

        var errors = result.Errors
            .Select(e => (IError)new ValidationError(e.PropertyName, e.ErrorMessage))
            .ToList();
        return Result<CreateOrderRequest>.Fail(errors);
    }

    public static async Task<Result<CreateOrderRequest>> ValidateAsync(
        this CreateOrderRequest instance,
        IValidator<CreateOrderRequest> validator,
        CancellationToken cancellationToken = default) { ... }
}

SmartEndpoints Generated Lambda

ordersGroup.MapPost("/", async (
    CreateOrderRequest req,
    IValidator<CreateOrderRequest> reqValidator,   // ← auto-injected
    IOrderService svc,
    CancellationToken cancellationToken) =>
{
    var validation = req.Validate(reqValidator);   // ← auto-emitted
    if (!validation.IsSuccess) return validation.ToIResult();

    var result = await svc.CreateOrder(req, cancellationToken);
    return result.ToIResult();
});

Rules

  • [FluentValidate] and [Validate] cannot both be applied to the same type (RESL1006 analyzer error)
  • Users install FluentValidation (≥ 11.x) separately — this package ships no runtime binary
  • Only POST/PUT body parameters trigger SmartEndpoints auto-injection (GET query params are skipped)

Requires

MIT License | Works with any .NET project (netstandard2.0)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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.54.0 113 4/6/2026
1.53.0 100 4/5/2026
1.52.0 100 3/30/2026
1.51.0 119 3/28/2026
1.50.1 96 3/25/2026
1.50.0 95 3/25/2026
1.49.0 97 3/24/2026
1.48.0 95 3/22/2026
1.47.5 97 3/22/2026
1.47.4 102 3/21/2026
1.47.3 105 3/20/2026
1.47.2 97 3/20/2026
1.47.1 101 3/18/2026
1.47.0 98 3/18/2026
1.46.3 100 3/18/2026
1.46.2 97 3/18/2026
1.46.1 94 3/17/2026
1.46.0 96 3/17/2026
1.45.0 96 3/17/2026
1.44.1 99 3/16/2026
Loading failed