fluentvalidation-patterns

Automate ABP input DTO validation with FluentValidation patterns.

24|5|Updated Nov 28, 2025
One-click install
npx skills add https://github.com/thapaliyabikendra/ai-artifacts --skill fluentvalidation-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fluentvalidation-patterns
Source: https://github.com/thapaliyabikendra/ai-artifacts/tree/main/.claude/skills/fluentvalidation-patterns
Command: npx skills add https://github.com/thapaliyabikendra/ai-artifacts --skill fluentvalidation-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides patterns for implementing robust input validation using FluentValidation in .NET applications, solving the challenge of inconsistent and boilerplate validation logic. It enables you to define clear, expressive, and reusable validation rules, ensuring data integrity and improving API reliability.

Core Features & Use Cases

  • Fluent API for Validation: Demonstrates how to define validation rules using FluentValidation's expressive API, making validators readable and maintainable.
  • Custom Validation Rules: Guides on creating custom validation rules for complex business logic that cannot be covered by built-in validators.
  • Asynchronous Validation: Patterns for performing asynchronous validation, such as checking for unique email addresses against a database.
  • Integration with ASP.NET Core: Shows how to integrate FluentValidation seamlessly into ASP.NET Core MVC/API, automatically validating DTOs and returning consistent error responses.
  • Use Case: A backend developer needs to validate user input for a CreateUserDto. Using this skill, they create a CreateUserDtoValidator with rules for email format, password complexity, and unique username, ensuring only valid data is processed.

Quick Start

Create a FluentValidation validator for a CreateProductDto that ensures the Name is not empty and the Price is greater than zero.

Frequently Asked Questions about fluentvalidation-patterns

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

FAQPage Schema
How do I validate input DTOs in ASP.NET Core APIs using FluentValidation?

FluentValidation provides a fluent API to define validation rules for DTOs. Create an AbstractValidator subclass, define rules using methods like NotEmpty() and MaximumLength(), then register validators via AddValidatorsFromAssembly in your ABP module to automatically validate incoming requests.

Can I perform async validation checks like verifying unique usernames against a database?

Yes, FluentValidation supports asynchronous validation through MustAsync(). This enables database or HTTP context lookups within validation rules, allowing you to check constraints like email uniqueness before data is processed.

What's the best way to implement custom validation rules for complex business logic?

Create custom validation rules by extending AbstractValidator and using Must() or MustAsync() methods to encapsulate complex business logic. This keeps validators reusable and maintainable across Create/Update DTOs in ABP modules.

How do I localize validation error messages in FluentValidation?

FluentValidation supports localized messages through WithMessage() and resource-based localization. Define translated error messages in resource files, then reference them in validator rules to return context-appropriate messages to API clients.

Does FluentValidation integrate directly with ABP framework applications?

Yes, FluentValidation integrates seamlessly with ABP through module registration via AddValidatorsFromAssembly. ABP automatically discovers and applies validators to input DTOs, returning consistent validation error responses across your application.

What are the limitations of built-in validators when handling scenario-specific validation?

Built-in validators like NotEmpty() and MaximumLength() cover basic rules but cannot handle conditional logic or business context. Custom validators with MustAsync() and repository access enable scenario-aware validation that adapts based on application state or user context.