A minimalist validation library for .NET built atop the existing features in `System.ComponentModel.DataAnnotations` namespace
A minimalist validation library for .NET built atop the existing features in `System.ComponentModel.DataAnnotations` namespace
A minimalistic validation library built atop the existing features in .NET's System.ComponentModel.DataAnnotations namespace. Adds support for single-line validation calls and recursion with cycle detection.
Supports .NET Standard 2.0 compliant runtimes.
Install the library from NuGet:
❯ dotnet add package MiniValidationIf installing into an ASP.NET Core 8+ project, consider using the MinimalApis.Extensions package instead, which adds extensions specific to ASP.NET Core, including a validation endpoint filter:
❯ dotnet add package MinimalApis.Extensionsvar widget = new Widget { Name = "" };
var isValid = MiniValidator.TryValidate(widget, out var errors);
class Widget
{
[Required, MinLength(3)]
public string Name { get; set; }
public override string ToString() => Name;
}……❯ widget.exe
Widget 'widget' is valid!
Widget has errors!
Name:
- Cannot name a widget 'widget'.
❯ widget.exe Ok
Widget has errors!
Name:
- The field Name must be a string or array type with a minimum length of '3'.
Widget has errors!
Name:
- The field Name must be a string or array type with a minimum length of '3'.
❯ widget.exe Widget
Widget 'Widget' is valid!
Widget has errors!
Name:
- Cannot name a widget 'Widget'.
❯ widget.exe MiniValidation
Widget 'MiniValidation' is valid!
Widget 'MiniValidation' is valid!…No open issues yet, or sync has not completed.