Sparkdo.Validation 1.0.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Sparkdo.Validation --version 1.0.1
                    
NuGet\Install-Package Sparkdo.Validation -Version 1.0.1
                    
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="Sparkdo.Validation" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.Validation" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Sparkdo.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 Sparkdo.Validation --version 1.0.1
                    
#r "nuget: Sparkdo.Validation, 1.0.1"
                    
#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 Sparkdo.Validation@1.0.1
                    
#: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=Sparkdo.Validation&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Sparkdo.Validation&version=1.0.1
                    
Install as a Cake Tool

Sparkdo.Validation

Sparkdo 验证库,提供基于数据注解的对象验证功能实现。

功能特性

  • 基于数据注解的对象验证
  • 支持递归验证复杂对象
  • 支持验证拦截器
  • 支持自定义验证贡献者
  • 本地化验证消息支持
  • 与 Sparkdo 框架无缝集成

安装

<PackageReference Include="Sparkdo.Validation" Version="x.x.x" />

核心组件

DefaultObjectValidator

默认对象验证器实现,提供基于数据注解的验证功能:

  • ValidateAsync(): 验证对象,如果验证失败则抛出异常
  • GetErrorsAsync(): 获取对象的验证错误列表

DataAnnotationObjectValidationContributor

数据注解验证贡献者,负责处理基于数据注解的验证逻辑:

  • 支持递归验证复杂对象
  • 支持验证 IEnumerable 类型
  • 支持 ValidationDisableAttribute 禁用验证

ValidationInterceptor

验证拦截器,用于拦截方法调用并验证参数:

  • 自动验证方法参数
  • 与 Sparkdo 代理机制集成

SparkdoValidationOptions

验证配置选项,允许自定义验证行为:

  • IgnoredTypes: 忽略验证的类型列表
  • ObjectValidationContributors: 对象验证贡献者类型列表

扩展性

该库提供了完整的验证功能实现,可以通过以下方式扩展:

  1. 实现自定义的 IObjectValidationContributor 来添加特定的验证逻辑
  2. 实现自定义的 IMethodInvocationValidator 来添加方法调用验证逻辑
  3. 实现自定义的 IAttributeValidationResultProvider 来处理特定验证属性的结果
  4. 通过 SparkdoValidationOptions 配置验证行为

代码结构说明

本项目包含以下主要组件:

验证器实现

  • DefaultObjectValidator: 默认对象验证器实现
  • DefaultMethodInvocationValidator: 默认方法调用验证器实现
  • DefaultAttributeValidationResultProvider: 默认属性验证结果提供者实现

验证贡献者

  • DataAnnotationObjectValidationContributor: 数据注解验证贡献者

拦截器

  • ValidationInterceptor: 验证拦截器
  • ValidationInterceptorConfigure: 验证拦截器配置

配置

  • SparkdoValidationOptions: 验证配置选项
  • SparkdoValidationModule: 验证模块配置

资源

  • SparkdoValidationResource: 验证资源
  • 本地化资源文件(en.json, zh-Hans.json)

所有公共接口和类都添加了详细的 XML 文档注释,便于开发者理解和使用。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Sparkdo.Validation:

Package Downloads
Sparkdo.Features

Sparkdo 功能系统库,提供功能定义、管理、检查和拦截功能

Sparkdo.FeatureManagement.Domain.Shared

Sparkdo 功能管理共享领域层,提供功能管理模块的共享资源、常量定义和数据传输对象

Sparkdo.SettingManagement.Domain.Shared

Sparkdo 设置管理领域共享库,提供设置管理模块的共享资源、常量定义和数据传输对象

Sparkdo.PermissionManagement.Domain.Shared

Sparkdo 权限管理领域共享库,提供权限管理功能的领域共享模型、接口定义和常量

Sparkdo.TenantManagement.Domain.Shared

Sparkdo 租户管理共享资源和配置

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2-preview.1 148 12/4/2025
1.0.1 977 11/27/2025
1.0.0 961 11/25/2025
1.0.0-preview.5 93 10/24/2025