AxisValidator 2.2.0
dotnet add package AxisValidator --version 2.2.0
NuGet\Install-Package AxisValidator -Version 2.2.0
<PackageReference Include="AxisValidator" Version="2.2.0" />
<PackageVersion Include="AxisValidator" Version="2.2.0" />
<PackageReference Include="AxisValidator" />
paket add AxisValidator --version 2.2.0
#r "nuget: AxisValidator, 2.2.0"
#:package AxisValidator@2.2.0
#addin nuget:?package=AxisValidator&version=2.2.0
#tool nuget:?package=AxisValidator&version=2.2.0
AxisValidator — Documentation
Declarative validation that returns AxisResult — IAxisValidator<T> with Validate / ValidateAsync, a bundled FluentValidation adapter, an AxisValidatorBase<T> with battle-tested rule helpers (NotNullOrEmpty, RequiredEmail, RequiredSlug, RequiredGuid7, dependent rules), an opt-in mediator pipeline behaviour that short-circuits on Failure, a AxisValidator.Brazil package for CPF / brazilian cellphone validation, and a AxisValidator.Usa package for SSN / U.S. phone validation.
public class CreatePersonValidator : AxisValidatorBase<CreatePersonCommand>
{
public CreatePersonValidator()
{
RequiredEmail (x => x.Email, "PERSON_EMAIL_INVALID");
RequiredSlug (x => x.Username, "PERSON_USERNAME_INVALID", length: 32);
RequiredGuid7 (x => x.TenantId, "TENANT_ID_INVALID");
}
}
Use this page as a map: read the trunk below (~5 min) and jump straight to the detail of the group you need — without reading hundreds of lines.
The trunk (read first)
The interface in 60 seconds
public interface IAxisValidator<in T>
{
AxisResult Validate(T instance);
Task<AxisResult> ValidateAsync(T instance);
}
A success returns AxisResult.Ok(). A failure returns AxisResult.Error(errors) where every error has Type = AxisErrorType.ValidationRule and the Code is the rule's error code. → The IAxisValidator<T> contract
The base — AxisValidatorBase<T>
A FluentValidation.AbstractValidator<T> with Axis-flavoured helpers. You inherit it, call helpers in the constructor, and the framework discovers your validator by assembly scan. → Validator base and rules
ValidationBehavior — pipeline-level enforcement
An opt-in IAxisPipelineBehavior that runs the validator (if any) before every mediator request. On Failure, the pipeline short-circuits with the validation errors — the handler never executes. → ValidationBehavior — pipeline enforcement
Brazilian localisation — AxisValidator.Brazil
CPF, brazilian cellphone, plus the BrazilValidator static facade for "format this cellphone" and "validate this CPF". → Brazilian validators
American localisation — AxisValidator.Usa
SSN, U.S. (NANP) phone, plus the UsaValidator static facade for "format this phone" and "validate this SSN". → American validators
Installation
dotnet add package AxisValidator # the abstraction + behaviour
dotnet add package AxisValidator.FluentValidation # the AbstractValidator base + adapter
dotnet add package AxisValidator.Brazil # CPF + brazilian cellphone helpers
dotnet add package AxisValidator.Usa # SSN + U.S. phone helpers
→ Full guide: Getting started
The map (jump to what you need)
| Group | You want to… | Detail |
|---|---|---|
Contract · IAxisValidator<T> |
run a validator and get an AxisResult |
iaxisvalidator.md |
Base · AxisValidatorBase<T> ⭐ |
declare a validator with Axis helpers |
validator-base.md |
Pipeline · ValidationBehavior |
enforce validation before every handler | validation-behavior.md |
Brazil · AxisValidator.Brazil |
CPF, cellphone, country extensions | brazil.md |
USA · AxisValidator.Usa |
SSN, phone, country extensions | usa.md |
| Why? | the case for Result-returning validation |
why-axisvalidator.md |
| Reference | every member at a glance | api-reference.md |
Start here: Getting started · The IAxisValidator<T> contract · Why AxisValidator?
Fundamentals: Validator base and rules · ValidationBehavior · Brazilian validators · American validators
Reference & extras: API reference
Design principles
- Validation returns
AxisResult. A failed rule is a value on the rail, not an exception in the handler. - One error code = one rule. Each rule fails with a stable
Code("PERSON_EMAIL_INVALID"). No prose, no message templates leaking into the contract. - Pipeline-level enforcement. Register the behaviour and the handler stops worrying about input — by the time it runs, the request is valid.
- FluentValidation underneath. Battle-tested library; the adapter translates failures into typed
AxisError.ValidationRule(code)entries. - Localisation is a separate package. Country-specific rules (CPF, brazilian cellphone; SSN, U.S. phone) live in
AxisValidator.BrazilandAxisValidator.Usaso the core stays neutral.
License
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
- AxisDependencyInjections.Abstractions (>= 2.2.0)
- AxisMediator.Contracts (>= 2.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AxisValidator:
| Package | Downloads |
|---|---|
|
AxisValidator.FluentValidation
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.