RecursiveDataAnnotationsValidation
Recursively validate DataAnnotations.
Install / Use
/learn @tgharold/RecursiveDataAnnotationsValidationREADME
RecursiveDataAnnotationsValidation
Allows recursive validation of sub-objects in a class when using DataAnnotations validation (also known as Attribute Validation). The current version of .NET Core's attribute validation does not handle objects within objects (or collections of objects). Therefore it is necessary to add some glue code to recurse through the object graph.
Installation
.NET Core
$ dotnet add package RecursiveDataAnnotationsValidation
Package Manager
PM> Install-Package RecursiveDataAnnotationsValidation
Usage
Usage of the recursive validation is nearly identical to using the standard validator.
var validator = new RecursiveDataAnnotationValidator();
var validationResults = new List<ValidationResult>();
var result = validator.TryValidateObjectRecursive(sut, validationResults);
There are more examples in the example and test projects.
SkipRecursiveValidationAttribute
The [SkipRecursiveValidation] attribute can be used on properties where you do not want to recursively validate. An example of this can be seen in SkippedChildrenExample.cs.
Build Status
Nuget Page
https://www.nuget.org/packages/RecursiveDataAnnotationsValidation/
Legacy
This package grew out of a need to recursively validate POCOs used for the .NET Core options pattern and is based on work by Mike Reust and his DataAnnotationsValidatorRecursive project. After doing a lot of experimentation, I went ahead and forked the project in order to make minor improvements, port it to .NET Standard, and experiment with using Github Actions.
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
