Validonce.FluentValidation 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Validonce.FluentValidation --version 0.2.0
                    
NuGet\Install-Package Validonce.FluentValidation -Version 0.2.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="Validonce.FluentValidation" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Validonce.FluentValidation" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Validonce.FluentValidation" />
                    
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 Validonce.FluentValidation --version 0.2.0
                    
#r "nuget: Validonce.FluentValidation, 0.2.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 Validonce.FluentValidation@0.2.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=Validonce.FluentValidation&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Validonce.FluentValidation&version=0.2.0
                    
Install as a Cake Tool

Validonce.FluentValidation

Write cross-field validation rules once, in FluentValidation. The server enforces them, and the same rules export as data in the validonce rule format, so clients can evaluate them too.

Install

dotnet add package Validonce.FluentValidation

For ASP.NET Core, install Validonce.AspNetCore instead. It brings this package and Validonce.

Example

using FluentValidation;
using Validonce;
using Validonce.FluentValidation;

public sealed record Signup(string? Plan, string? Company, DateOnly? Start, DateOnly? End, string? Email, string? Phone);

public sealed class SignupValidator : ValidonceValidator<Signup>
{
    public SignupValidator()
    {
        RequiredWhen(x => x.Company, If.Eq(x => x.Plan, "pro")).WithMessageKey("rules.company_required");
        Compare(x => x.End, CompareOp.Ge, x => x.Start).WithMessageKey("rules.end_after_start");
        AtLeastOneOf(x => x.Email, x => x.Phone).WithMessageKey("rules.contact_required");
        RuleFor(x => x.Email).EmailAddress();   // ordinary FluentValidation rules work alongside
    }
}

var result = new SignupValidator().Validate(new Signup("pro", null, null, null, null, null));
// result.Errors: ErrorCode is the message key, CustomState is the Validonce Issue.

var ruleData = new SignupValidator().ExportRules().ToJson();   // the value of x-validonce

Rules

  • RequiredWhen(field, condition) with If.Eq / Ne / In / Present / Absent / All / Any / Not.
  • Compare(left, op, right) against another property or a constant: numbers, string, DateOnly, DateTimeOffset.
  • AtLeastOneOf, ExactlyOneOf and AllOrNone over two or more properties. .AtPath(...) reports on another property.
  • Every rule takes .WithMessageKey(...), .WithRuleId(...), .ServerOnly() and .WithMessage(...).

Field names in the rule data are wire names: [JsonPropertyName] if present, otherwise the naming policy of the JsonSerializerOptions you pass to the base constructor (default camelCase).

The rule format is described at https://github.com/metatoy/validonce/blob/main/docs/rule-format-v1.md. Source and issues: https://github.com/metatoy/validonce.

Copyright 2026 Metatoy LLC. Licensed under the Apache License, Version 2.0.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Validonce.FluentValidation:

Package Downloads
Validonce.AspNetCore

ASP.NET Core integration for validonce: adds your FluentValidation cross-field rules to the OpenAPI document and returns 422 problem details with the issue list.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 97 11/30/2026
0.5.0 106 11/25/2026
0.4.0 106 11/24/2026
0.3.3 114 11/24/2026
0.3.1 100 11/24/2026
0.3.0 104 11/24/2026
0.2.0 290 11/23/2026