Validonce 0.3.0

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

Validonce

Write validation rules once on the server and enforce them everywhere. This package is the core library for .NET.

This package contains:

  • The regex pattern linter (Validonce.Patterns). It finds regular expressions that behave differently in JavaScript, Python, Rust and .NET, so a pattern in your OpenAPI document does not pass on one side and fail on the other.
  • The rule-format evaluator (Validonce). RuleSet.Parse reads validonce rules and Evaluator.Evaluate runs them against JSON data. The rule kinds are required_when, compare, and the group kinds at_least_one_of, exactly_one_of and all_or_none.

To write the rules in FluentValidation and serve them from ASP.NET Core, use Validonce.FluentValidation and Validonce.AspNetCore.

Evaluate rules

using System.Text.Json.Nodes;
using Validonce;

var rules = RuleSet.Parse(xValidonceJson);   // the x-validonce value from an OpenAPI schema
var data = JsonNode.Parse("""{"email":null,"phone":null}""")!.AsObject();
foreach (var issue in Evaluator.Evaluate(rules.Rules, data))
    Console.WriteLine($"{string.Join('.', issue.Path)} {issue.Key}");

Pass EvaluationSide.Client to skip rules marked server-only.

Lint a pattern

using Validonce.Patterns;

foreach (var f in PatternLinter.Lint(@"^\w+$"))
{
    Console.WriteLine($"{f.Id} {f.Severity} at {f.Start}: {f.Message}");
    if (f.Rewrite is not null) Console.WriteLine($"  suggested: {f.Rewrite}");
}

// Only care about some engines:
var options = new LintOptions(new HashSet<Engine> { Engine.Js, Engine.DotNet });
var findings = PatternLinter.Lint(@"^\d+$", options);

Engines: Js, JsU (the u flag), PythonRe, RustRegex (Pydantic's default), DotNet. All use search semantics. PatternLinter.Findings lists every finding the linter can report. The full table is at https://github.com/metatoy/validonce/blob/main/docs/regex-findings.md.

To lint a whole OpenAPI document from the command line, install the Validonce.Cli tool: dotnet tool install -g Validonce.Cli.

Copyright 2026 Metatoy LLC. Licensed under Apache-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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Validonce:

Package Downloads
Validonce.FluentValidation

Write cross-field validation rules once with FluentValidation (required-when, compare fields, at least one of, exactly one of, all or none) and export them for browser forms.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 107 11/30/2026
0.5.0 121 11/25/2026
0.4.0 117 11/24/2026
0.3.3 119 11/24/2026
0.3.1 113 11/24/2026
0.3.0 124 11/24/2026
0.2.0 311 11/23/2026
0.1.0 90 11/23/2026