Open Closed

Question on validation of extended properties from dependent Abp modules #2896


User avatar
0
balessi75 created

Abp Commercial 5.2.0 / Blazor Server / EF Core / Non-tiered

Hi, We are using the ObjectExtensionManager to create a custom property on the IdentityUser entity and would like to do validation that requires an App Service call.

In the documentation (https://docs.abp.io/en/abp/latest/Object-Extensions#custom-validation) we see that custom validation can be accomplished with:

 options.Validators.Add(context =>
            {... }

... and that context.ServiceProvider can be used to call an application service for advanced validation scenarios.

The problem we are having is that ObjectExtensionManager is templated to reside in the Domain.Shared project which cannot have a reference to our application services due to circular dependency issues.

Are we missing something here, or is there a better/recommended way of accomplishing what we are looking for?

Thanks in advance, Brian


1 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @balessi75

    You can't reference any application layer in the domain layer. That violates DDD and also it's a circular dependency. If you have to add a validation to a DTO you can define it in Application.Contracts layer. You should use AppService interfaces since they're placed in the same layer and the runnable end application registers their implementations if it's a client proxy or application service instance.

    As a note, if you convert your project to tiered or micro-service architecture, you have to know that appservice interface implementation will be replaced with client proxy implementation and it'll make a HTTP request for each usage.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11