Validation samples
Validation has separate console and ASP.NET Core sample projects. Each runnable
choice owns its description on its Sample or Startup class; Program.cs
only selects which one to execute.
Core validation
Run the console project:
dotnet run --project validation/samples/Valiant.Validation.Samples
Select one delegate in
Program.cs:
| Delegate | Demonstrates | Source |
|---|---|---|
Basic.Sample.RunAsync | A minimal fluent validator, generated registration, validation, and failure output | Basic |
AttributeValidation.Sample.RunAsync | Validation attributes on the model with the generated validator contract | AttributeValidation |
DependencyInjection.Sample.RunAsync | Generated registrations, configurable lifetime and defaults, concrete non-default validators, property validators, and metadata providers | DependencyInjection |
SyncAndAsyncValidation.Sample.RunAsync | Sync and async APIs, boolean helpers, and the guard against synchronously invoking an asynchronous validator | SyncAndAsyncValidation |
Severity.Sample.RunAsync | Error, warning, and information severities, including valid warning-only and information-only results | Severity |
CompositionAndPaths.Sample.RunAsync | Whole-model composition, reusable property validators, child contexts, collection items, and nested/indexed paths | CompositionAndPaths |
FailureHandling.Sample.RunAsync | Per-property fail-fast behavior, result helpers, and ThrowIfFailed() | FailureHandling |
ControlFlowAndCollections.Sample.RunAsync | Collection and dictionary rules, conditions, switches, indexed validation, and native loops | ControlFlowAndCollections |
The
Catalog
folder is shared support code for the advanced scenarios, not an additional
selectable sample.
ASP.NET Core validation
Run the web project:
dotnet run --project validation/samples/Valiant.Validation.AspNetCore.Samples
Select one startup in
Program.cs:
| Startup | Demonstrates | Source |
|---|---|---|
MinimalApi.Startup | Typed and all-parameter Minimal API filters that reject invalid requests before the handler runs | MinimalApi |
Mvc.Startup | Automatic MVC validation without a validator dependency or manual validation branch in the controller | Mvc |
ProblemDetails.Startup | Manual validation converted to HTTP and MVC validation problem-details responses | ProblemDetails |
OpenApi.Startup | Generated Valiant validation metadata projected into the application's OpenAPI document | OpenApi |
The
Orders
folder contains the shared request models and validator; it is not a startup
choice.
The web scenarios are also exercised through WebApplicationFactory, so the
sampled registration and HTTP behavior stay covered by the validation test
project. See ASP.NET Core and OpenAPI for
consumer setup.