wshaddix avatar

Validation Patterns

This walks through the validation layer cake in ASP.NET Core, from DataAnnotations up through FluentValidation and options validation at startup. You get decision trees for picking the right approach (simple attributes vs IValidatableObject vs custom ValidationAttribute), tables of built-in attributes including the .NET 8 additions like AllowedValues and Base64String, and working examples of cross-property validation and MediatR pipeline behaviors. The IValidateOptions pattern for catching bad configuration at startup is especially worth having around. It's comprehensive enough that you'll reference it when setting up validation in a new project or when you need to remember the syntax for custom validators that need database access.

skills.sh installs
542
GitHub stars
90
last updated
Aug 21, 2026

Install

$ npx -y skills add wshaddix/dotnet-skills --skill validation-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Validation Patterns in ASP.NET Core

Rationale

Validation is critical for both security and user experience. Poor validation leads to invalid data, security vulnerabilities, and confusing error messages. These patterns provide a comprehensive approach to validation at multiple layers.

Validation Strategy

LayerPurposeTechnology
Client-SideImmediate feedback, reduce server loadjQuery Validation, HTML5
Model BindingData type/format validationModel Binders
ApplicationBusiness rule validationFluentValidation, DataAnnotations
ConfigurationStartup validationIValidateOptions
DatabaseConstraint enforcementEF Core Configurations

Validation Approach Decision Tree

Choose the validation approach based on complexity:

Sponsors

Details

Repository
github.com/wshaddix/dotnet-skills
Categories
DevOps & CI/CD, Automation & Workflows, Sales & Marketing, .NET & C#
First seen
Jun 3, 2026

More from wshaddix/dotnet-skills

All 13
1awslabs avatardsqlawslabs/mcpBuild with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, load data, and develop applications with a serverless, distri541skills.sh installs
2openclaudia avatarcontent-strategyopenclaudia/openclaudia-skillsBuild content strategies, editorial calendars, topic clusters, and content plans. Map content to buyer journey stages and plan distribution. Trigger phrases: "c541skills.sh installs
3teneoprotocolai avatarteneo-cliteneoprotocolai/teneo-skillsTeneo CLI — 39 commands for browse & query network agents, send commands to agents, room management, deploy & manage your own agents, wallet management, daemon 541skills.sh installs
4pskoett avatarsimplify-and-hardenpskoett/pskoett-ai-skillsPost-completion self-review for coding agents that runs simplify, harden, and micro-documentation passes on non-trivial code changes. Use when: a coding task is540skills.sh installs
5wanshuiyin avatarpaper-compilewanshuiyin/auto-claude-code-research-in-sleepCompile LaTeX paper to PDF, fix errors, and verify output. Use when user says "编译论文", "compile paper", "build PDF", "生成PDF", or wants to compile LaTeX into a su539skills.sh installs
6wshaddix avatarproject-structurewshaddix/dotnet-skillsGuidelines for organizing .NET projects, including solution structure, project references, folder conventions, .slnx format, centralized build properties, and c539skills.sh installs