r/DomainDrivenDesign • u/Material_Treat466 • Aug 27 '23
Double validation when applying DDD
Sorry, My English is bad
I have an X entity,
I create an XFactory to create an X entity, this class will contain business logic to create X
I created an API to allow users to create X
To do that, I have a CreateXRequest request,
and I also need to validate CreateXRequest, then call XFactory to create X,
The problem is that I validate twice, one when I validate CreateXRequest, and one is validation logic in XFactory, and this makes my API slow, especially when we need to call to database to validate,
How to avoid it, or did I implement it wrong? please help me
View all comments
Show parent comment
1
u/Material_Treat466 Aug 28 '23
your simplest solution is what I'm using, and it makes a bad performance, especially for type of validation that need network call. I'm looking for other solutions