Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

System.ComponentModel.DataAnnotations Validation — Maintainer's Guide

This repository contains a comprehensive guide to .NET's System.ComponentModel.DataAnnotations validation system. It covers everything from built-in attributes through advanced extensibility, and explores the path toward adding async validation to DataAnnotations. The material is designed to bring a team up to speed so they can build a project plan for adding async validation across the entire .NET product suite.

Chapters

  1. Built-In Validation Attributes — Complete catalog of attributes shipped with .NET
  2. Creating Custom Validation Attributes — Deriving from ValidationAttribute for reusable rules
  3. Annotating Objects for Validation — Applying attributes to properties and classes
  4. Programmatic (Manual) Validation — Using the Validator class directly
  5. ASP.NET MVC Automatic Validation — How model binding triggers validation
  6. Advanced Custom ValidationIValidatableObject and complex validation scenarios
  7. ValidationContext Deep Dive — Services, Items dictionary, and context propagation
  8. The ValidationResult API — Understanding validation results and error reporting
  9. The Async Validation Gap — Why DataAnnotations lacks async support today
  10. Strickland — Parallel Concepts and Async Validation — Lessons from a JavaScript validation framework
  11. The History of DataAnnotations Integration Across .NET — Chronological history of every integration point
  12. The Async Validation Prototype — A Working Demo — Analysis of a working async validation prototype
  13. Object Graph Validation — Recursive walks, result representation, and ecosystem solutions

Appendices

Suggested Reading Order

For team members who are new to DataAnnotations validation, the recommended reading order below starts with the foundational blog series, moves through official API documentation, then application model integration, and finishes with async validation concepts.

Phase 1: Historical Foundation (RIA Services Blog Series)

DataAnnotations validation saw its most significant innovation during the .NET RIA Services era (2009–2012), when APIs like IValidatableObject, ValidationResult, ValidationContext, and Validator were designed and refined. The 2010 RIA Services Validation blog series was written against RIA Services but covers the universal DataAnnotations framework, and it remains one of the most thorough walkthroughs available.

  1. Standard Validators[Required], [Range], [StringLength], [RegularExpression]; error messages and localization
  2. Custom Validation Methods — Using [CustomValidation] to delegate to static methods
  3. Custom Reusable Validators — Deriving from ValidationAttribute; the IsValid(object, ValidationContext) override
  4. Attribute Propagation — How validators flow between tiers
  5. Validation Triggers — When validation is invoked
  6. Cross-Field Validation — Validating one property based on another
  7. Entity-Level Validation — Class-level validation and the 4-stage pipeline
  8. Providing ValidationContext — Items dictionary, IServiceProvider, ServiceContainer
  9. Using ValidationContext (Cross-Entity Validation) — Service-based validators that access data stores
  10. ViewModel Validation with Entity Rules — Reusing validation across view models

Additional Resources:

Phase 2: Modern .NET API Documentation

  1. System.ComponentModel.DataAnnotations Namespace
  2. Validator Class API
  3. ValidationAttribute Class
  4. ValidationContext Class
  5. ValidationResult Class

Phase 3: Application Model Integration

  1. ASP.NET Core MVC Model Validation
  2. Blazor Forms Validation
  3. Options Pattern ValidationValidateDataAnnotations(), ValidateOnStart()
  4. EF Core Data Annotations
  5. ASP.NET Core OpenAPI
  6. WPF Data Validation
  7. WinForms Input Validation

Phase 4: Async Validation Concepts

  1. Strickland Documentation / GitHub
  2. Strickland: Inspiration
  3. Strickland: Two-Stage Sync/Async Validation

Phase 5: Integration History and Working Prototype

  1. Chapter 11: The History of DataAnnotations Integration Across .NET — Chronological history of every integration point with PR/issue citations
  2. Chapter 12: The Async Validation Prototype — A Working Demo — Analysis of the oroztocil/validation-demo branch
  3. Microsoft.Extensions.Validation design issue (dotnet/aspnetcore#46349) — Unified validation design proposal
  4. Minimal API validation PR (dotnet/aspnetcore#60724) — Core implementation of Minimal API validation

About This Material

  • Core source analysisdotnet/runtime, dotnet/aspnetcore, dotnet/efcore, and dotnet/aspire repositories, tracing validation integration history through PRs and commits
  • Historical foundation — The RIA Services Validation blog series (2010) and research into how RIA Services and OpenRiaServices approached async validation patterns
  • Official documentation — Microsoft Learn conceptual and API docs for ASP.NET Core MVC, Blazor, Options pattern, EF Core, OpenAPI, WPF, and WinForms validation
  • Async validation prototype — Analysis of the oroztocil/validation-demo branch and the Microsoft.Extensions.Validation design
  • Ecosystem researchStrickland (JavaScript validation framework), MiniValidation (Damian Edwards), FluentValidation, Blazor component vendors (MudBlazor, Radzen, Telerik, Syncfusion, DevExpress), API frameworks (FastEndpoints, ServiceStack), and schema generators (Swashbuckle, NSwag)
  • The material targets team members who will work on adding async validation across the .NET product suite

License

This repository is licensed under the MIT License. See the LICENSE file for details.

About

Maintainer's Guide for DataAnnoations Validation

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors