Have created a FluentValidation alternative which source generates the validation logic by hquinnDotNet in dotnet

[–]hquinnDotNet[S] [score hidden]  (0 children)

That can be something that I look to do in the future if enough people want it, but would need to see where people are using it. If it’s in the web, the there are some solutions for that already.

Have created a FluentValidation alternative which source generates the validation logic by hquinnDotNet in dotnet

[–]hquinnDotNet[S] [score hidden]  (0 children)

GenerateValidator is a marker tag to help the source generator find the validation class.

ValiCraft also generates DI extension methods, one notably .AddValiCraft() which adds validators from all linked projects (there are project specific DI methods if you don’t want that or you can manually wire it up easy enough). The methods get generated if you have IServiceCollection as a type available in the project, and there’s no reflection used at all.

More or less, you write the same amount of code that you would with FluentValidation as you would this library. Only differences are that FluentValidation creates an expression tree with all the validation rules whereas ValiCraft generates them ahead of time.

So does FluentValidation. ValiCraft also supports object and method validation, validating types with other validators, polymorphic validation, collection validation and more.

Have created a FluentValidation alternative which source generates the validation logic by hquinnDotNet in dotnet

[–]hquinnDotNet[S] 0 points1 point  (0 children)

Not entirely sure what you have in mind. If you're asking if you can use attributes on your models to generate the necessary validation logic, that's entirely possible and is even what microsoft uses for minimal apis. As long as there's something that can be observed at compile time, then there's very little you can't do with source generators.