LocalizedString.FluentValidation 1.0.1

dotnet add package LocalizedString.FluentValidation --version 1.0.1
NuGet\Install-Package LocalizedString.FluentValidation -Version 1.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="LocalizedString.FluentValidation" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LocalizedString.FluentValidation --version 1.0.1
#r "nuget: LocalizedString.FluentValidation, 1.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.
// Install LocalizedString.FluentValidation as a Cake Addin
#addin nuget:?package=LocalizedString.FluentValidation&version=1.0.1

// Install LocalizedString.FluentValidation as a Cake Tool
#tool nuget:?package=LocalizedString.FluentValidation&version=1.0.1

A helper library for FluentValidation that allows for easy declaration of error messages in various languages without the use of resource files. When ValidationResult is produced, the value of Thread.CurrentThread.CurrentCulture will be used to resolve the translations for the ErrorMessage fields.

Useful for short strings. If strings are getting longer -- consider switching to time-tested technique of using resource files.

The library uses LocalizedString, get more info here

Example:

class Student
{
    public string Name { get; set; }
    public double GPA { get; set; }
}

class StudentValidator : AbstractValidator<Student>
{
    public StudentValidator()
    {
        RuleFor(x => x.Name).MinimumLength(3).WithMessage(
            "Name must be at least 3 characters long".Localize()
            .InFrench("Le name must be at least 3 characters long")
            .InCanadianFrench("Le name must be at least 3 characters long, éh")
            .In("de-DE", "Das name must be at least 3 characters long"));

        RuleFor(x => x.GPA).Must(x => x >= 0 && x <= 4.0).WithMessage(
            "Must be from 0 to 4".Localize()
            .InFrench("Must be from 0 to 4, comprendre?")
            .InCanadianFrench("Must be from 0 to 4, s'il vous plaît")
            .In("de-DE", "Must be from 0 to 4, verstehen?"));
    }
}

var student = new Student()
{
    Name = "TJ",
    GPA = 4.1
};

var validator = new StudentValidator();

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(string.Empty); // invariant

var validationResult = validator.Validate(student);

Console.WriteLine(validationResult.Errors[0].ErrorMessage); // Name must be at least 3 characters long

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-DE");

validationResult = validator.Validate(student);

Console.WriteLine(validationResult.Errors[0].ErrorMessage); // Das name must be at least 3 characters long
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.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. 
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
1.0.1 576 5/14/2019

v1.0.1 - Renamed package so as to not collide with reserved FluentValidation prefix
v1.0.0 - Initial Release