fluent-validation-custom-validation

Implements custom async FluentValidation rules inside existing C# validator files.

23|10|Updated Aug 31, 2017
One-click install
npx skills add https://github.com/IntentArchitect/Intent.Modules --skill fluent-validation-custom-validation-intentarchitect
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fluent-validation-custom-validation
Source: https://github.com/IntentArchitect/Intent.Modules/tree/main/Tests/Accelerators/.agents/skills/fluent-validation-custom-validation
Command: npx skills add https://github.com/IntentArchitect/Intent.Modules --skill fluent-validation-custom-validation-intentarchitect

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing custom async validation methods in FluentValidation validators often leads to invented business logic, broken layer boundaries, and infrastructure leakage into application code. This Skill enforces a disciplined workflow where every line of validation logic is traceable to an explicit requirement in the codebase. ## Core Features & Use Cases - Custom Async Validation Implementation: Fills in or corrects custom validation method bodies in existing *Validator.cs files while preserving method signatures and IntentManaged attributes. - Layer Boundary Enforcement: Ensures validators only depend on Domain or Application layer abstractions, never on Entity Framework, Dapper, DbContexts, or other infrastructure types. - Evidence-Based Logic: Requires every validation rule to be traceable to XML documentation, comments, domain rules, value objects, or existing tests, and asks targeted questions when evidence is missing. - Use Case: When implementing a uniqueness check for a CreateCustomerCommand validator, the Skill searches for existing repository abstractions, extends them with an ExistsByAsync-style method if needed, and reports failures via validationContext.AddFailure. ## Quick Start Implement the custom async validation method in my CreateCustomerCommandValidator.cs following the existing domain patterns and repository abstractions.

Frequently Asked Questions about fluent-validation-custom-validation

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

FAQPage Schema
How do I write a custom async validation method in FluentValidation?▼

Implement the method body inside the existing validator file without changing its signature, retrieve required data through a Domain or Application repository abstraction, and report failures using validationContext.AddFailure. Thread cancellation tokens through all async calls.

How to validate business rules that require database access in FluentValidation?▼

Use an existing repository or domain service abstraction from the Domain or Application layers rather than querying infrastructure directly. If the capability is missing, extend the abstraction with expressive methods like ExistsByAsync or IsAvailableAsync.

Can FluentValidation validators reference Entity Framework or DbContext directly?▼

No, validators should never depend on infrastructure types such as Entity Framework, Dapper, concrete DbContexts, or SQL clients. Keep validators focused on orchestration and delegate data access to repository abstractions in allowed layers.

What should I do when a validation rule has no documented requirement?▼

Do not invent logic from naming or intuition. Search XML documentation, inline comments, domain rules, value objects, and existing tests first; if no explicit evidence exists, ask the user what rule, failure message, and data source the method should use.

Why must the IntentManaged attribute use Body Mode.Ignore for custom validation methods?▼

Setting Body to Mode.Ignore prevents the code generator from overwriting the hand-written method body while still managing the rest of the file. This keeps custom validation logic intact across regeneration cycles.