FluentValidationGenerator 0.1.98
See the version list below for details.
dotnet add package FluentValidationGenerator --version 0.1.98
NuGet\Install-Package FluentValidationGenerator -Version 0.1.98
<PackageReference Include="FluentValidationGenerator" Version="0.1.98" />
paket add FluentValidationGenerator --version 0.1.98
#r "nuget: FluentValidationGenerator, 0.1.98"
// Install FluentValidationGenerator as a Cake Addin #addin nuget:?package=FluentValidationGenerator&version=0.1.98 // Install FluentValidationGenerator as a Cake Tool #tool nuget:?package=FluentValidationGenerator&version=0.1.98
FluentValidationGenerator
A Code Generator for automatically generating FluentValidation Classes for .NET 7+ with predefined Rules.
The Generator uses MediatR Commands which inherit from the IRequest<>
interface to automatically Generate Fluent Validator Classes.
Clean Architecture is the recommended Solution Architecture.
Plans
✅ Create Fluent Validators based on MediatR commands which follow the Clean Architecture
❌ Tests
❌ Create Fluent Validators for ASP.NET Core API's based on an OpenAPI specification
Usage
For Usage please refer to the Sample Project
FluentValidationGenerator.Generator
takes the Assembly which contains the Commands and the Solution Folder as Parameters.
The easiest way to get your Solution Folder should be:
Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()))
This should result in:
var generator = new FluentValidationGenerator.Generator(
typeof(CreateWeatherForecastCommand).Assembly,
Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()))!);
generator.GenerateValidators();
The Generator should generate a File looking similar to the following Code, depending on the amount of Parameters
using FluentValidation;
namespace SampleNET7.Application.Messages.Commands;
public class CreateWeatherForecastCommandValidator : AbstractValidator<CreateWeatherForecastCommand>
{
public CreateWeatherForecastCommandValidator()
{
RuleFor(t => t.Summaries).NotEmpty().WithMessage("Summaries Can not be Empty");
RuleFor(t => t.TemperatureC).NotEmpty().WithMessage("TemperatureC Can not be Empty");
RuleFor(t => t.TestString).NotEmpty().WithMessage("TestString Can not be Empty");
}
}
The Generator will NOT Generate a Rule for Nullable Properties
<br> <a href="https://www.buymeacoffee.com/DawnDevelop"><img src="https://img.buymeacoffee.com/button-api/?text=Coffee 😃&emoji=☕&slug=DawnDevelop&button_colour=17a4d3&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=FFDD00" /></a>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
-
net7.0
- DotLiquid (>= 2.2.677)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.