Olve.Validation
0.38.0
dotnet add package Olve.Validation --version 0.38.0
NuGet\Install-Package Olve.Validation -Version 0.38.0
<PackageReference Include="Olve.Validation" Version="0.38.0" />
<PackageVersion Include="Olve.Validation" Version="0.38.0" />
<PackageReference Include="Olve.Validation" />
paket add Olve.Validation --version 0.38.0
#r "nuget: Olve.Validation, 0.38.0"
#:package Olve.Validation@0.38.0
#addin nuget:?package=Olve.Validation&version=0.38.0
#tool nuget:?package=Olve.Validation&version=0.38.0
Olve.Validation
Fluent validation helpers built on top of Olve.Results. Validators accumulate rules and return a Result containing all problems found.
Installation
dotnet add package Olve.Validation
Overview
| Type | Description |
|---|---|
StringValidator |
String validation: null checks, length constraints, allowed/disallowed values. |
IntValidator |
Integer validation: numeric range, even/odd. |
DecimalValidator<T> |
Generic numeric validation for any INumber<T> type. |
EnumerableValidator<T> |
Collection validation: empty, duplicates, count. |
ListValidator<T> |
Optimized collection validation for IList<T>. |
IValidator<T> |
Interface for any validator that returns Result. |
IValidatable |
Interface for objects that can validate their own state. |
Usage
String validation
Chain rules to build a validator, then call Validate() to get a Result.
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L12-L16
var result = new StringValidator()
.CannotBeNullOrWhiteSpace()
.MustHaveMinLength(3)
.MustHaveMaxLength(50)
.Validate("Alice");
When multiple rules fail, all problems are collected into the result:
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L24-L34
var result = new StringValidator()
.CannotBeNullOrWhiteSpace()
.MustHaveMinLength(3)
.Validate("");
// Multiple rules can fail at once — all problems are collected
if (result.TryPickProblems(out var problems))
{
foreach (var p in problems)
Console.WriteLine(p.Message);
}
Numeric validation
IntValidator provides integer-specific rules like MustBeEven() and MustBeOdd() on top of the standard numeric range methods.
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L43-L46
var result = new IntValidator()
.MustBePositive()
.MustBeLessThan(100)
.Validate(42);
DecimalValidator<T> works with any INumber<T> type (double, decimal, float, etc.):
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L54-L56
var result = new DecimalValidator<double>()
.MustBeBetween(0.0, 1.0)
.Validate(0.5);
Collection validation
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L64-L68
var result = new EnumerableValidator<string>()
.CannotBeNull()
.CannotBeEmpty()
.CannotContainDuplicates()
.Validate(new[] { "a", "b", "c" });
ListValidator<T> provides the same API optimized for IList<T>.
Custom error messages
Use WithMessage() or WithProblem() after a rule to override its default error:
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L76-L87
var result = new StringValidator()
.CannotBeNullOrWhiteSpace()
.WithMessage("Username is required")
.MustHaveMinLength(3)
.WithMessage("Username must be at least 3 characters")
.Validate(null);
if (result.TryPickProblems(out var problems))
{
foreach (var p in problems)
Console.WriteLine(p.Message);
}
Integration with Olve.Results
Validators return Result, so they compose naturally with the rest of the Olve.Results API:
// ../../tests/Olve.Validation.Tests/ReadmeDemo.cs#L95-L104
Result ValidateEmail(string? email)
{
return new StringValidator()
.CannotBeNullOrWhiteSpace()
.WithMessage("Email is required")
.Validate(email);
}
var valid = ValidateEmail("user@example.com");
var invalid = ValidateEmail(null);
Documentation
Full API reference: https://olivervea.github.io/Olve.Utilities/api/Olve.Validation.html
License
MIT License © OliverVea
| 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
- Olve.Results (>= 0.38.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Olve.Validation:
| Package | Downloads |
|---|---|
|
Olve.Utilities
Various pieces of utility |
|
|
Olve.MinimalApi
Minimal API extensions for ASP.NET Core including JSON conversion for IPath, result mapping, and validation helpers |
|
|
Olve.Logging
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.38.0 | 298 | 2/19/2026 |
| 0.37.2 | 113 | 2/18/2026 |
| 0.37.1 | 104 | 2/18/2026 |
| 0.37.0 | 110 | 2/17/2026 |
| 0.36.1 | 398 | 11/15/2025 |
| 0.36.0 | 206 | 11/15/2025 |
| 0.35.2 | 195 | 11/9/2025 |
| 0.35.1 | 172 | 11/8/2025 |
| 0.35.0 | 167 | 11/8/2025 |
| 0.34.0 | 164 | 10/4/2025 |
| 0.33.0 | 153 | 9/13/2025 |
| 0.32.2 | 219 | 8/9/2025 |
| 0.32.1 | 209 | 8/9/2025 |
| 0.32.0 | 253 | 8/8/2025 |
| 0.31.0 | 334 | 8/5/2025 |
| 0.30.0 | 143 | 8/3/2025 |
| 0.29.1 | 128 | 8/3/2025 |
| 0.29.0 | 132 | 8/3/2025 |
| 0.28.2 | 112 | 8/2/2025 |