Validates DTOs/inputs and throws/localizes business errors in an ABP app. Covers data annotations, IValidationEnabled, FluentValidation, BusinessException/UserFriendlyException, error codes, localization, and HTTP status code mapping.
Ships in abp-module-development. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
ABP builds on ASP.NET Core model validation and adds automatic validation, localization, and a standard exception-handling pipeline. Everything from the ASP.NET Core validation docs still applies.
IValidatableObject.IValidationEnabled.BusinessException / UserFriendlyException.AbpAuthorizationException policy — use permissions-and-authorization / authorize-resources; here it appears only in the status-code mapping table.Use standard data annotation attributes on DTOs. When a DTO is a parameter to an application service or controller action, ABP validates it automatically and throws an AbpValidationException on failure. (The attribute messages are localized only when the DTO's assembly is registered for data-annotations localization — see below — otherwise the raw attribute message is used.)
public class CreateBookDto
{
[Required]
[StringLength(100)]
public string Name { get; set; }
[Range(0, 999.99)]
public decimal Price { get; set; }
}
For custom cross-field logic, implement IValidatableObject:
public class CreateBookDto : IValidatableObject
{
[Required] public string Name { get; set; }
[Required] public string Description { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Name == Description)
{
yield return new ValidationResult(
"Name and Description can not be the same!",
new[] { "Name", "Description" });
}
}
}
Keep DTOs simple — don't put domain logic in Validate. Data annotation error messages are localized only when the DTO's assembly is registered for it (via AddDataAnnotationsLocalization / AbpMvcDataAnnotationsLocalizationOptions.AssemblyResources); otherwise the raw attribute message is used.
IValidationEnabled is an empty marker interface. Any DI-registered class that implements it gets automatic method-argument validation. All application services implement it already. ABP uses dynamic proxying/interception, so the method must be virtual or the service must be called through an interface.
public class MyService : ITransientDependency, IValidationEnabled
{
public virtual async Task DoItAsync(MyInput input) { /* input is validated */ }
}
Disable with [DisableValidation] on a method, class, or property.
ABP throws AbpValidationException when validation fails. Its ValidationErrors holds the error list, its log level is Warning, and ABP converts it to an HTTP 400 response automatically. You can throw it yourself but rarely need to.
Add the Volo.Abp.FluentValidation package (abp add-package Volo.Abp.FluentValidation) and depend on AbpFluentValidationModule. Then write standard FluentValidation validators — ABP discovers them and runs them as part of the same validation pipeline.
public class CreateUpdateBookDtoValidator : AbstractValidator<CreateUpdateBookDto>
{
public CreateUpdateBookDtoValidator()
{
RuleFor(x => x.Name).Length(3, 10);
RuleFor(x => x.Price).ExclusiveBetween(0.0f, 999.0f);
}
}
Most of your own errors are business exceptions. BusinessException implements IBusinessException, IHasErrorCode, IHasErrorDetails, and IHasLogLevel (default log level Warning). All its constructor arguments are optional; usually you set an error Code or a Message.
throw new BusinessException(QaErrorCodes.CanNotVoteYourOwnAnswer);
The Code follows the format <code-namespace>:<error-code> (e.g. Volo.Qa:010002). The code-namespace is unique to your module/application and is the key used for localization.
Attach message parameters via the Data dictionary; there is a WithData shortcut that is chainable:
throw new BusinessException("App:010046").WithData("UserName", "john");
Two models:
User-friendly exceptions. UserFriendlyException implements IUserFriendlyException (which derives from IBusinessException). ABP sends its Message and Details to the client unchanged — no localization needed, or localize it yourself with the string localizer at throw time.
throw new UserFriendlyException(_stringLocalizer["UserNameShouldBeUniqueMessage", "john"]);
Error codes (recommended for advanced cases). Instead of localizing at throw time, map a code-namespace to a localization resource once, then localize by the error code key. This avoids needing the localizer everywhere (e.g. in static contexts or entity methods).
services.Configure<AbpExceptionLocalizationOptions>(options =>
{
options.MapCodeNamespace("Volo.Qa", typeof(QaResource));
});
Add the error code as a key in the resource's en.json:
{
"culture": "en",
"texts": {
"Volo.Qa:010002": "You can not vote your own answer!",
"App:010046": "Username should be unique. '{UserName}' is already taken!"
}
}
If no localized string is defined for a code, ABP sends a default error message to the client — it does not fall back to the exception's Message property. Use UserFriendlyException when you want the raw message shown.
ABP picks a status code automatically for common exception types:
AbpAuthorizationException → 401 if not logged in, 403 if logged inAbpValidationException → 400EntityNotFoundException → 404AbpDbConcurrencyException → 409IBusinessException / IUserFriendlyException → 403NotImplementedException → 501500 (treated as an infrastructure error)Override per error code with AbpExceptionHttpStatusCodeOptions:
services.Configure<AbpExceptionHttpStatusCodeOptions>(options =>
{
options.Map("Volo.Qa:010002", HttpStatusCode.Conflict);
});
AbpValidationException → HTTP 400 response, with validationErrors populated in the JSON.BusinessException with a mapped error code and confirm the localized text from en.json reaches the client (not the raw Message).RemoteServiceErrorResponse with a single error object holding code / message.AbpExceptionHttpStatusCodeOptions.Map(...) returns the overridden status code.AddDataAnnotationsLocalization / AbpMvcDataAnnotationsLocalizationOptions.AssemblyResources); otherwise the raw attribute message shows.IValidationEnabled needs the method to be virtual or the service to be called through an interface — ABP relies on dynamic proxying/interception, so direct concrete calls to non-virtual methods bypass validation.Message. Use UserFriendlyException when you want the raw message shown.RemoteServiceErrorResponse with a single error object (a RemoteServiceErrorInfo) holding code, message, details, data, and validationErrors — i.e. { "error": { "code": ..., "message": ... } } — filled based on which interfaces the exception implements.AbpExceptionHandlingOptions (SendExceptionsDetailsToClients, SendStackTraceToClients).IHasLogLevel; add extra logging with IExceptionWithSelfLogging.ExceptionSubscriber and override HandleAsync.What SKILL.md sets; muted values are Claude Code's defaults
/abp-module-development:handle-validation-and-errorsfrom abp-module-development
npx claudepluginhub abpframework/abp-skills --plugin abp-module-development13 skills in this plugin
/application-servicesWrites or reviews an ABP application service — the DTO-taking, DTO-returning boundary between the domain and the presentation/API layer. USE FOR: implementing IApplicationService/ApplicationService for non-CRUD use cases, using AbstractKeyCrudAppService for composite or non-standard keys, and unit-of-work basics. DO NOT USE FOR: exposing application services as auto/conventional API controllers, routes, verbs or [RemoteService] (use expose-http-apis); a complete standard-key CrudAppService workflow (use build-crud-application-services); detailed object-to-DTO mapping mechanics/profiles (use map-objects-and-dtos); DTO validation attributes and business exceptions (use handle-validation-and-errors); permission definitions and authorization policy (use permissions-and-authorization); the overall layered project structure (use layered-architecture).
/build-crud-application-servicesBuilds or reviews a complete ABP CRUD application-service contract and implementation with the CrudAppService APIs. USE FOR: choosing ICrudAppService/CrudAppService generic overloads, separating get/list/create/update DTOs, wiring IRepository, object mappings and five policy properties, adding list filters without breaking count/sort/page order, and validating all five CRUD operations. DO NOT USE FOR: a non-CRUD use case or general ApplicationService orchestration (use application-services); composite or non-standard keys with AbstractKeyCrudAppService (use application-services); mapping-provider configuration details (use map-objects-and-dtos); permission definitions (use permissions-and-authorization); optimistic concurrency (use handle-optimistic-concurrency); HTTP endpoint conventions (use expose-http-apis); integration-test infrastructure (use test-abp-applications).
Other plugins' skills for the same job