Koto.Validation
0.3.0-preview.3
dotnet add package Koto.Validation --version 0.3.0-preview.3
NuGet\Install-Package Koto.Validation -Version 0.3.0-preview.3
<PackageReference Include="Koto.Validation" Version="0.3.0-preview.3" />
<PackageVersion Include="Koto.Validation" Version="0.3.0-preview.3" />
<PackageReference Include="Koto.Validation" />
paket add Koto.Validation --version 0.3.0-preview.3
#r "nuget: Koto.Validation, 0.3.0-preview.3"
#:package Koto.Validation@0.3.0-preview.3
#addin nuget:?package=Koto.Validation&version=0.3.0-preview.3&prerelease
#tool nuget:?package=Koto.Validation&version=0.3.0-preview.3&prerelease
Koto.Validation
FluentValidation extensions and a CQRS pipeline behavior for the Koto suite.
Uses FluentValidation v12 (Apache 2.0 on all versions), pinned to
[12.0.0,13.0.0).
Install
dotnet add package Koto.Validation
What's included
| Type | Purpose |
|---|---|
KotoValidators.MustBeValueObject<T, TSource, TValueObject> |
Validates a property by calling a domain factory (Func<TSource, Result<TVO>>) — any source type: string, int, Guid, … |
KotoValidators.MustBeEntity<T, TElement, TEntity> |
Same contract for entity factories (reads naturally for entities) |
KotoValidators.ListMustContainNumberOfItems |
Min/max count rule for collections |
KotoValidators.NotEmptyWithKotoError / LengthWithKotoError |
Built-in rules carrying Errors.General codes |
ValidationBehavior<TRequest, TResponse> |
Pipeline middleware — runs all validators (async-capable) before the handler |
ServiceCollectionExtensions.AddKotoValidation |
Registers the behavior and scans assemblies for validators |
Usage
Register
builder.Services.AddKotoValidation(typeof(Program).Assembly);
// Registers ValidationBehavior<,> as an open generic and scans for IValidator<T> —
// no extra registration needed. Recommended behavior order: Logging → Validation → Transaction.
Write a validator — one source of truth
The validation logic lives in the domain factory; the validator only calls it:
public sealed class PlaceOrderValidator : AbstractValidator<PlaceOrderCommand>
{
public PlaceOrderValidator()
{
RuleFor(x => x.Email).MustBeValueObject(Email.Create); // string source
RuleFor(x => x.Quantity).MustBeValueObject(Quantity.Create); // int source — any type works
RuleFor(x => x.Items).ListMustContainNumberOfItems(1, 100);
RuleFor(x => x.CustomerId).NotEmpty();
}
}
Validators are keyed by the concrete command type and discovered by the pipeline
automatically (the dispatcher closes ValidationBehavior<,> over PlaceOrderCommand).
Structured errors
Each domain Error travels as structured state — ValidationFailure.CustomState +
ErrorCode — not as a serialized message string. On failure, ValidationBehavior
returns a Result carrying one Error per validation failure, each with its real
Code, Message, and Field (the property name). Nothing is collapsed into a single
string; HTTP layers can render RFC 7807 validation problem details per field
(see Koto.Api.AspNetCore).
Async rules (MustAsync, CustomAsync) are fully supported — the behavior calls ValidateAsync.
| 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
- FluentValidation (>= 12.0.0 && < 13.0.0)
- Koto.Application (>= 0.3.0-preview.3)
- Koto.Domain (>= 0.3.0-preview.3)
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 |
|---|---|---|
| 0.3.0-preview.3 | 48 | 7/11/2026 |
| 0.3.0-preview.2 | 49 | 7/11/2026 |
| 0.3.0-preview.1 | 50 | 7/3/2026 |
| 0.2.0-preview.1 | 59 | 6/28/2026 |
| 0.1.0-preview.5 | 70 | 5/13/2026 |
| 0.1.0-preview.4 | 58 | 5/13/2026 |
| 0.1.0-preview.3 | 58 | 5/13/2026 |
| 0.1.0-preview.2 | 63 | 5/11/2026 |