Validonce 0.3.1
See the version list below for details.
dotnet add package Validonce --version 0.3.1
NuGet\Install-Package Validonce -Version 0.3.1
<PackageReference Include="Validonce" Version="0.3.1" />
<PackageVersion Include="Validonce" Version="0.3.1" />
<PackageReference Include="Validonce" />
paket add Validonce --version 0.3.1
#r "nuget: Validonce, 0.3.1"
#:package Validonce@0.3.1
#addin nuget:?package=Validonce&version=0.3.1
#tool nuget:?package=Validonce&version=0.3.1
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 apatternin your OpenAPI document does not pass on one side and fail on the other. - The rule-format evaluator (
Validonce).RuleSet.Parsereads validonce rules andEvaluator.Evaluateruns them against JSON data. The rule kinds arerequired_when,compare, and the group kindsat_least_one_of,exactly_one_ofandall_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 | Versions 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. |
-
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.