Nullean.Entities.FluentValidation 0.5.0

dotnet add package Nullean.Entities.FluentValidation --version 0.5.0
                    
NuGet\Install-Package Nullean.Entities.FluentValidation -Version 0.5.0
                    
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="Nullean.Entities.FluentValidation" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nullean.Entities.FluentValidation" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Nullean.Entities.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 Nullean.Entities.FluentValidation --version 0.5.0
                    
#r "nuget: Nullean.Entities.FluentValidation, 0.5.0"
                    
#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 Nullean.Entities.FluentValidation@0.5.0
                    
#: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=Nullean.Entities.FluentValidation&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Nullean.Entities.FluentValidation&version=0.5.0
                    
Install as a Cake Tool

Nullean.Entities.FluentValidation

Nullean.Entities

Keep your FluentValidation pipeline: your constraints run inside it as validators, and your validators run as constraints that generated data can attack.

NuGet

Without this package, a team with FluentValidation validators and Nullean.Entities constraints keeps two sets of rules apart: the HTTP or mediator pipeline only sees the validators, and the property tests only see the constraints. This package bridges FluentValidation both ways.

It builds on Nullean.Entities and FluentValidation (Apache-2.0); it does not need the other integration packages. It uses no reflection of its own, but it is not trim or NativeAOT clean, because FluentValidation is not. Built and tested against FluentValidation 12.2.0.

Install

Targets net10.0 and net11.0.

dotnet add package Nullean.Entities
dotnet add package Nullean.Entities.FluentValidation

Quick start

Constraints inside FluentValidation: register the set as a validator, or add it to one you have.

using FluentValidation;
using Nullean.Entities;
using Nullean.Entities.FluentValidation;

services.AddSingleton<IValidator<Customer>>(CustomerRules.All.ToValidator());

public sealed class SignUpValidator : AbstractValidator<Customer>
{
	public SignUpValidator()
	{
		RuleFor(c => c.Name).NotEmpty();
		Include(CustomerRules.All.ToValidator());
		RuleFor(c => c.Address).SatisfiesConstraints(AddressRules.All);   // failures keyed "Address.City"
		RuleForEach(c => c.Lines).SatisfiesConstraints(LineRules.All);    // "Lines[1].Quantity"
	}
}

FluentValidation inside constraints: turn an existing validator into a constraint, and attack it in a test (with Nullean.Entities.CsCheck).

var rules = new CustomerValidator().ToConstraintSet();          // or Constraints<Customer>.FromValidator(validator, "customer-validator")

rules.Probe(samples: 500);                                      // held N, violated M: the validator both passes and fails on generated data
GenAuto.Of<Customer>().ShouldSatisfy(rules);                    // throws with the smallest generated value it rejects and a seed to replay

What you get

  • ConstraintSet<T>.ToValidator() and ConstraintValidator<T>: an AbstractValidator<T> over a set, for DI, Include, SetValidator, or as a base class.
  • RuleFor(...).SatisfiesConstraints(set) and RuleForEach(...).SatisfiesConstraints(set): a property or each item checked against its own set.
  • Each violation as a ValidationFailure: PropertyName is Violation.Member under the rule's property path (no member: the path, or the rule id at the root), ErrorCode the rule id, Severity Error/Warning/Info from Error/Warning/Hint, AttemptedValue the Evidence, CustomState the Violation. ConstraintValidation.ToFailure is the mapping on its own.
  • Constraints<T>.FromValidator(validator, name), validator.ToConstraint(name) and validator.ToConstraintSet(name): a validator as a point-in-time constraint, each failure a Violation with Member from PropertyName and Evidence from AttemptedValue (ValidatorConstraints.ToViolation).

Pitfalls and limits

  • Severity exists in both FluentValidation and Nullean.Entities: alias one (using FvSeverity = FluentValidation.Severity;).
  • Only point-in-time rules run inside FluentValidation; a validator sees one value, not a change. A null property is skipped; add NotNull() when null is wrong.
  • FromValidator runs the validator synchronously, as every constraint is checked: a validator with MustAsync/CustomAsync rules throws AsyncValidatorInvokedSynchronouslyException.
  • One validator is one constraint: Probe counts the validator, not each RuleFor. FluentValidation's ErrorCode is not kept on the way in.
  • Not trim or NativeAOT clean (FluentValidation compiles expressions). Other FluentValidation versions than 12.2.0 are untested.

Learn more

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 89 11/12/2026
0.4.0 89 11/11/2026
0.3.0 97 11/4/2026