Ling.FluentValidation
1.0.0-preview.2
dotnet add package Ling.FluentValidation --version 1.0.0-preview.2
NuGet\Install-Package Ling.FluentValidation -Version 1.0.0-preview.2
<PackageReference Include="Ling.FluentValidation" Version="1.0.0-preview.2" />
<PackageVersion Include="Ling.FluentValidation" Version="1.0.0-preview.2" />
<PackageReference Include="Ling.FluentValidation" />
paket add Ling.FluentValidation --version 1.0.0-preview.2
#r "nuget: Ling.FluentValidation, 1.0.0-preview.2"
#:package Ling.FluentValidation@1.0.0-preview.2
#addin nuget:?package=Ling.FluentValidation&version=1.0.0-preview.2&prerelease
#tool nuget:?package=Ling.FluentValidation&version=1.0.0-preview.2&prerelease
Ling.FluentValidation
Ling.FluentValidation provides the source generator, FluentValidation rule extensions, and compatible runtime validators. The generator is shipped as a compiler-only asset, while DTO declarations live in the dependency-free Ling.FluentValidation.Annotations package.
Installation
Install the package in the application or validation project that should own generated validators:
<PackageReference Include="Ling.FluentValidation" Version="..." />
The package references Ling.FluentValidation.Annotations transitively, including its analyzer and code-fix assets. Contract projects should nevertheless reference Ling.FluentValidation.Annotations directly and should not reference this runtime package.
Generate from a contract assembly
using Ling.FluentValidation.Annotations;
using MyApplication.Contracts;
[assembly: GenerateValidatorsFromAssemblyContaining(typeof(CreateOrderRequest))]
[assembly: ValidatorGenerationOptions(
Namespace = "MyApplication.Validation",
Visibility = GeneratedValidatorVisibility.Public)]
Only explicitly selected referenced assemblies are examined. Marked DTOs in the current assembly are generated automatically.
Extend a generated validator
Generated validators are partial and expose a parameterless constructor plus ConfigureAdditionalRules:
using FluentValidation;
using MyApplication.Contracts;
namespace MyApplication.Validation;
public sealed partial class CreateOrderRequestValidator
{
partial void ConfigureAdditionalRules()
{
RuleFor(request => request.Name)
.Must(name => !name.StartsWith("test-"))
.WithMessage("Reserved order name.");
}
}
For rules with dependencies, add a constructor that chains to the generated constructor:
public CreateOrderRequestValidator(IOrderPolicy policy) : this()
{
RuleFor(request => request.Name)
.MustAsync(policy.IsAllowedAsync);
}
Register generated validators
Every receiving assembly gets a GeneratedValidatorRegistry containing target-to-validator mappings. When DI abstractions are referenced, a conventional extension method is generated too:
var services = new ServiceCollection();
services.AddGeneratedValidators();
Registration uses generated concrete types and does not scan assemblies.
Other assemblies can retrieve the generated validator types directly:
IReadOnlyList<Type> validatorTypes =
GeneratedValidatorRegistry.ValidatorTypes;
IReadOnlyDictionary<Type, Type> validatorsByTargetType =
GeneratedValidatorRegistry.ValidatorTypesByTargetType;
The returned collection is read-only and stable for the generated assembly.
Localization
The first Ling rule extension adds Ling messages directly to the current manager when it derives from FluentValidation.Resources.LanguageManager. It never replaces the manager or changes its settings:
ValidatorOptions.Global.LanguageManager.Culture = new CultureInfo("zh-CN");
Custom ILanguageManager implementations can import every entry from LingValidatorTranslations.All; a one-time Trace warning is emitted when automatic registration is unavailable.
Supported frameworks
Runtime assets are provided for:
- .NET Standard 2.0 and 2.1
- .NET Core 3.1
- .NET 5 through .NET 10
The package uses a tested FluentValidation major-version range for each target framework.
Related packages
Ling.FluentValidation.Annotationscontains dependency-free declarations, analyzers, and code fixes.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- FluentValidation (>= 9.0.1 && < 10.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
.NETStandard 2.0
- FluentValidation (>= 11.11.0 && < 12.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
.NETStandard 2.1
- FluentValidation (>= 11.11.0 && < 12.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
net10.0
- FluentValidation (>= 12.0.0 && < 13.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
net5.0
- FluentValidation (>= 11.11.0 && < 12.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
net6.0
- FluentValidation (>= 11.11.0 && < 12.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
net7.0
- FluentValidation (>= 11.11.0 && < 12.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
net8.0
- FluentValidation (>= 12.0.0 && < 13.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
-
net9.0
- FluentValidation (>= 12.0.0 && < 13.0.0)
- Ling.FluentValidation.Annotations (>= 1.0.0-preview.2)
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 |
|---|---|---|
| 1.0.0-preview.2 | 74 | 8/31/2026 |
| 1.0.0-preview.1 | 63 | 8/31/2026 |