Robotico.Validation 1.0.3

Robotico.Validation

Woodpecker CI

Result-based validation for .NET 8 and .NET 10. Defines IValidator<T> (Validate returns Result). Integrates with Robotico.Mediator's validation pipeline and Robotico.Result for validation errors.

.NET 8 .NET 10 C# GitHub Packages Build

Features

  • IValidator<T> — Validate(instance) returns Result; success or Result.ValidationError(...).
  • ValidationErrors — Helpers to build field-to-messages dictionaries: ForField(name, message), ToResult(errors), and a ValidationErrorsBuilder to collect errors then call ToResult().
  • Works with Robotico.Mediator — Register validators per request type; ValidationPipelineBehavior runs them before handlers.

Installation

dotnet add package Robotico.Validation

Quick start

using Robotico.Validation;
using VoidResult = Robotico.Result.Result;

// Implement IValidator<T>
public sealed class CreateUserValidator : IValidator<CreateUserRequest>
{
    public VoidResult Validate(CreateUserRequest request)
    {
        ValidationErrorsBuilder errors = ValidationErrors.CreateBuilder();
        if (string.IsNullOrWhiteSpace(request.Name))
            errors.Add("Name", "Name is required.");
        if (request.Age < 0)
            errors.Add("Age", "Age must be non-negative.");
        return errors.ToResult();
    }
}

// Or use ValidationErrors directly
VoidResult r = ValidationErrors.ForField("email", "Invalid format.");

Versioning

We follow Semantic Versioning. Version 1.0.0 is the first stable release. No breaking changes in minor/patch versions.

Documentation

See this README for usage and examples; the library follows the same quality bar as Robotico.Result.

Building and testing

From the repo root:

dotnet restore
dotnet build -c Release
dotnet test tests/Robotico.Validation.Tests/Robotico.Validation.Tests.csproj -c Release

With coverage:

dotnet test tests/Robotico.Validation.Tests/Robotico.Validation.Tests.csproj -c Release --collect:"XPlat Code Coverage"

Principal quality target: 90% line coverage. Optional CI gate (fail if below threshold) using the included runsettings:

dotnet test tests/Robotico.Validation.Tests/Robotico.Validation.Tests.csproj -c Release --collect:"XPlat Code Coverage" --settings tests/Robotico.Validation.Tests/coverlet.runsettings

Or with inline properties:

dotnet test tests/Robotico.Validation.Tests/Robotico.Validation.Tests.csproj -c Release --collect:"XPlat Code Coverage" /p:CollectCoverage=true /p:Threshold=90 /p:ThresholdType=line

Or open robotico-validation.slnx in your IDE and build from there.

Contributing

Run tests and coverage locally (see Building and testing). Open a pull request; ensure the build and 90% line-coverage gate pass. Code style is enforced via .editorconfig and analyzers.

License

See repository license file.

No packages depend on Robotico.Validation.

.NET 8.0

.NET 10.0

Version Downloads Last updated
1.0.3 6 07/26/2026
1.0.2 3 06/03/2026