百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

MiniValidation

> 编程语言
开源

一个基于 `System.ComponentModel.DataAnnotations` 命名空间中现有功能的简洁验证库

390 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个基于 `System.ComponentModel.DataAnnotations` 命名空间中现有功能的简洁验证库

MiniValidation

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.

Installation

Install the library from NuGet:

bash
❯ dotnet add package MiniValidation

ASP.NET Core 8+ Projects

If 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:

bash
❯ dotnet add package MinimalApis.Extensions

Example usage

Validate an object

csharp
var 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;
}

Use services from validators

…

Console app

…
bash
❯ 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!

Web app (.NET 8+)

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言