Pitasoft.FluentValidation 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pitasoft.FluentValidation --version 2.0.1
                    
NuGet\Install-Package Pitasoft.FluentValidation -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="Pitasoft.FluentValidation" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pitasoft.FluentValidation" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Pitasoft.FluentValidation" />
                    
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 Pitasoft.FluentValidation --version 2.0.1
                    
#r "nuget: Pitasoft.FluentValidation, 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 Pitasoft.FluentValidation@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=Pitasoft.FluentValidation&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Pitasoft.FluentValidation&version=2.0.1
                    
Install as a Cake Tool

Pitasoft.FluentValidation

NuGet version Build Status License: MIT .NET 8.0 .NET 9.0 .NET 10.0

English | Castellano


English

FluentValidation integration for the Pitasoft.Validation ecosystem.

This package allows using validators created with FluentValidation within the Pitasoft validation system, as well as providing extension methods for direct object validation.

Installation

You can install this package via NuGet:

dotnet add package Pitasoft.FluentValidation

Features

  • Transparent integration with Pitasoft.Validation.
  • Register FluentValidation validators in Pitasoft's Validator<T>.
  • Extension methods for direct object validation.
  • Support for multiple .NET versions (net8.0, net9.0, net10.0).

Usage

Registering in a Pitasoft Validator

You can add a FluentValidation validator to a Pitasoft Validator<T> object using the RegisterFluentValidator extension method:

using Pitasoft.Validation;
using Pitasoft.FluentValidation.Extensions;
using FluentValidation;

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public class PersonFluentValidator : AbstractValidator<Person>
{
    public PersonFluentValidator()
    {
        RuleFor(x => x.Name).NotEmpty().WithMessage("Name is required.");
        RuleFor(x => x.Age).GreaterThan(0).WithMessage("Age must be greater than 0.");
    }
}

// ... in your business code ...
var validator = new Validator<Person>();
validator.RegisterFluentValidator(new PersonFluentValidator());

var person = new Person { Name = "", Age = 0 };
var result = validator.Validate(person);

if (!result.IsValid)
{
    foreach (var error in result.Errors)
    {
        Console.WriteLine($"{error.Key}: {string.Join(", ", error.Value)}");
    }
}
Direct Object Validation

You can also use extension methods directly on any object:

using Pitasoft.FluentValidation.Extensions;

var person = new Person { Name = "", Age = 0 };
var fluentValidator = new PersonFluentValidator();

// Get error collection
var errors = person.ValidateWithFluent(fluentValidator);

// Or try validate (TryParse style)
if (!person.TryValidateWithFluent(fluentValidator, out var errorCollection))
{
    // Handle errors...
}

License

This project is licensed under the MIT license. See the LICENSE.txt file for more details.

Author

Sebastián Martínez Pérez - Pitasoft, S.L.

Copyright © 2020-2026 Pitasoft, S.L.


Castellano

Integración de FluentValidation para el ecosistema de validación de Pitasoft.Validation.

Este paquete permite utilizar validadores creados con FluentValidation dentro del sistema de validación de Pitasoft, así como proporcionar métodos de extensión para validar objetos de forma directa.

Instalación

Puedes instalar este paquete a través de NuGet:

dotnet add package Pitasoft.FluentValidation

Características

  • Integración transparente con Pitasoft.Validation.
  • Registro de validadores de FluentValidation en el Validator<T> de Pitasoft.
  • Métodos de extensión para validación directa de objetos.
  • Soporte para múltiples versiones de .NET (net8.0, net9.0, net10.0).

Uso

Registro en un Validador de Pitasoft

Puedes añadir un validador de FluentValidation a un objeto Validator<T> de Pitasoft utilizando el método de extensión RegisterFluentValidator:

using Pitasoft.Validation;
using Pitasoft.FluentValidation.Extensions;
using FluentValidation;

public class Persona
{
    public string Nombre { get; set; }
    public int Edad { get; set; }
}

public class PersonaFluentValidator : AbstractValidator<Persona>
{
    public PersonaFluentValidator()
    {
        RuleFor(x => x.Nombre).NotEmpty().WithMessage("El nombre es obligatorio.");
        RuleFor(x => x.Edad).GreaterThan(0).WithMessage("La edad debe ser mayor que 0.");
    }
}

// ... en tu código de negocio ...
var validator = new Validator<Persona>();
validator.RegisterFluentValidator(new PersonaFluentValidator());

var persona = new Persona { Nombre = "", Edad = 0 };
var result = validator.Validate(persona);

if (!result.IsValid)
{
    foreach (var error in result.Errors)
    {
        Console.WriteLine($"{error.Key}: {string.Join(", ", error.Value)}");
    }
}
Validación Directa de Objetos

También puedes usar métodos de extensión directamente sobre cualquier objeto:

using Pitasoft.FluentValidation.Extensions;

var persona = new Persona { Nombre = "", Edad = 0 };
var fluentValidator = new PersonaFluentValidator();

// Obtener colección de errores
var errors = persona.ValidateWithFluent(fluentValidator);

// O intentar validar (estilo TryParse)
if (!persona.TryValidateWithFluent(fluentValidator, out var errorCollection))
{
    // Manejar errores...
}
---

### Autor

Sebastián Martínez Pérez

### License
Copyright © 2026 Pitasoft, S.L.
Licensed under the [LICENSE.txt](LICENSE.txt) provided in this repository.


Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 Pitasoft.FluentValidation:

Package Downloads
Pitasoft.FluentValidation.AspNetCore

ASP.NET Core integration for FluentValidation. Provides Minimal API endpoint filters and MVC action filters to validate request parameters using FluentValidation.IValidator<T> and returns Pitasoft.Result validation responses.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 174 4/1/2026
2.0.1 121 3/5/2026
1.0.0 262 4/11/2024