csharp-validation

Validate C# input models with layered validation boundaries in ASP.NET Core.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/CloudyWing/ai-dotfiles --skill csharp-validation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-validation
Source: https://github.com/CloudyWing/ai-dotfiles/tree/main/skills/csharp-validation
Command: npx skills add https://github.com/CloudyWing/ai-dotfiles --skill csharp-validation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides clear, production-oriented guidance to eliminate inconsistent or misplaced input validation in C# applications by defining distinct responsibilities for format validation, business-rule checks, and domain invariants and by prescribing framework-specific integration patterns.

Core Features & Use Cases

  • Layered validation guidance: Clarifies which checks belong to model binding, service layer, and domain model to avoid duplication and maintainability issues.
  • Framework selection rules: When to use DataAnnotations versus FluentValidation and the rule to avoid mixing them for the same validation layer.
  • Integration patterns: Advice for MVC automatic ModelState handling, Minimal API endpoint filters, FluentValidation registration, and error message conventions (Traditional Chinese).
  • Defensive validation principles: Best practices for validation at system boundaries, constructor guards for domain invariants, and avoiding over-defensive repeated checks.
  • Use case: Code review or implementation of API request models, selecting validators, and ensuring consistent error messages and integration across an ASP.NET Core project.

Quick Start

Ask the skill to review a request model and return recommended DataAnnotations or a FluentValidation validator with Traditional Chinese error messages and integration notes for ASP.NET Core.

Frequently Asked Questions about csharp-validation

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

FAQPage Schema
How do I structure C# input validation across different layers in ASP.NET Core?

C# input validation should be split across layers: use model binding for format checks, the service layer for business rules, and domain constructors for invariant guards. This prevents duplication and maintains boundaries.

When should I use FluentValidation versus DataAnnotations in ASP.NET Core?

Choose FluentValidation or DataAnnotations based on project complexity, but never mix them within the same validation layer. This framework selection rule ensures consistent validation logic and avoids conflicting model binding checks.

How do I integrate FluentValidation with Minimal APIs in ASP.NET Core?

For Minimal API integration, apply endpoint filters to execute FluentValidation checks before processing. You must also follow proper validator registration conventions and define consistent error message conventions for failed requests.

How do I enforce consistent Traditional Chinese error messages in C# model validation?

To enforce consistent Traditional Chinese error messages, define explicit message conventions within DataAnnotations or FluentValidation validators. This ensures consistent Traditional Chinese error messages across all ASP.NET Core validation layers.

What are the limitations of over-defensive validation in C# domain models?

Over-defensive validation causes unnecessary repeated checks throughout the domain model. Limit validation to constructor guards for domain invariants and perform boundary checks once at system entry points to avoid redundancy.