AxisValidator 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package AxisValidator --version 2.0.1
                    
NuGet\Install-Package AxisValidator -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AxisValidator" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AxisValidator" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AxisValidator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AxisValidator --version 2.0.1
                    
#r "nuget: AxisValidator, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AxisValidator@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AxisValidator&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AxisValidator&version=2.0.1
                    
Install as a Cake Tool

AxisValidator — Documentation

🌐 Português (documentação navegável)

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

  1. Validation returns AxisResult. A failed rule is a value on the rail, not an exception in the handler.
  2. One error code = one rule. Each rule fails with a stable Code ("PERSON_EMAIL_INVALID"). No prose, no message templates leaking into the contract.
  3. Pipeline-level enforcement. Register the behaviour and the handler stops worrying about input — by the time it runs, the request is valid.
  4. FluentValidation underneath. Battle-tested library; the adapter translates failures into typed AxisError.ValidationRule(code) entries.
  5. Localisation is a separate package. Country-specific rules (CPF, brazilian cellphone; SSN, U.S. phone) live in AxisValidator.Brazil and AxisValidator.Usa so the core stays neutral.

License

Apache 2.0

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
2.2.0 300 7/21/2026
2.1.1 134 7/17/2026
2.1.0 132 7/17/2026
2.0.1 146 7/15/2026
2.0.0 157 7/15/2026