XY.AspNetCore.Mvc.Validation 2.0.9

dotnet add package XY.AspNetCore.Mvc.Validation --version 2.0.9
                    
NuGet\Install-Package XY.AspNetCore.Mvc.Validation -Version 2.0.9
                    
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="XY.AspNetCore.Mvc.Validation" Version="2.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XY.AspNetCore.Mvc.Validation" Version="2.0.9" />
                    
Directory.Packages.props
<PackageReference Include="XY.AspNetCore.Mvc.Validation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XY.AspNetCore.Mvc.Validation --version 2.0.9
                    
#r "nuget: XY.AspNetCore.Mvc.Validation, 2.0.9"
                    
#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.
#:package XY.AspNetCore.Mvc.Validation@2.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XY.AspNetCore.Mvc.Validation&version=2.0.9
                    
Install as a Cake Addin
#tool nuget:?package=XY.AspNetCore.Mvc.Validation&version=2.0.9
                    
Install as a Cake Tool

XY.AspNetCore.Mvc.Validation

面向 Microsoft.AspNetCore.Mvc 的参数验证扩展类库,提供基于 ControllerBase 的链式 ModelState 校验能力。

功能

  • 通过 Validator(...) 快速创建校验容器
  • 支持空值、正则、Email、手机号、IP、URL、长度、字节长度、枚举、数值区间等常用校验
  • 校验失败自动写入 ModelState
  • 支持 stopWhileFail 失败即中断链式校验

使用示例

var result = this.Validator(input.Email, "邮箱", "Email", false)
    ?.NotNullOrEmpty(true)
    ?.IsEmail(true)
    ?.MaxLength(100, true);

if (!ModelState.IsValid)
{
    return BadRequest(ModelState);
}

目标框架

  • net6.0
  • net10.0
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.

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
2.0.9 69 5/5/2026
2.0.8 95 4/27/2026

[新增] Added
     - 增补 Controller 参数链式校验能力说明与使用场景说明。
     [优化] Improved
     - 统一 NuGet 元数据格式(Description/Tags/README/Icon/License/Repository)。
     [修复] Fixed
     - 修正发布说明与版本信息一致性,优化包检索呈现。