validation-patterns

Implement validation patterns for ASP.NET Core using FluentValidation and DataAnnotations.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill validation-patterns-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: validation-patterns
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/validation-patterns
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill validation-patterns-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to implementing robust data validation in ASP.NET Core applications, ensuring data integrity and security.

Core Features & Use Cases

  • Multi-Layered Validation: Covers client-side, model binding, application logic, and configuration validation.
  • Diverse Techniques: Demonstrates DataAnnotations, Custom Attributes, IValidatableObject, IValidateOptions<T>, FluentValidation, and MediatR pipeline behaviors.
  • Use Case: You need to implement complex validation rules for a user registration form, including cross-field checks, asynchronous email uniqueness validation, and password strength requirements.

Quick Start

Implement FluentValidation for your ASP.NET Core application by adding the necessary NuGet packages and registering validators from your assembly.

Frequently Asked Questions about validation-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement FluentValidation in an ASP.NET Core application?

FluentValidation integration in ASP.NET Core involves adding the necessary NuGet packages and registering validators from your assembly. This Skill provides patterns for setup, custom validators, and integrating them into the request pipeline.

What's the best way to validate complex cross-field rules in ASP.NET Core?

Cross-field validation in ASP.NET Core can be handled using IValidatableObject for model-level checks or FluentValidation for complex rule sets. This Skill demonstrates patterns for user registration forms including password strength and cross-field dependencies.

How does MediatR pipeline behavior handle model validation in ASP.NET Core?

MediatR pipeline behavior validates commands before they reach the handler by intercepting requests and checking model state. This Skill shows how to implement validation pipeline behaviors to ensure data integrity before application logic executes.

How do I validate configuration options using IValidateOptions<T> in .NET?

IValidateOptions<T> validates strongly-typed configuration objects at startup by implementing the interface and registering it with the options system. This Skill covers configuration validation patterns to ensure invalid settings fail early.

Should I use DataAnnotations or FluentValidation for ASP.NET Core model validation?

DataAnnotations provides built-in declarative validation while FluentValidation offers better separation of concerns and complex rule testing. This Skill demonstrates both techniques, covering custom attributes and FluentValidation integration for robust data integrity.

Can I perform asynchronous validation like email uniqueness checking in ASP.NET Core?

Asynchronous validation for scenarios like email uniqueness is supported through FluentValidation's async validators. This Skill provides patterns for implementing async checks alongside password strength requirements and cross-field validation.