dimanche 7 juin 2020

Asp.Net Core: How to reuse validations for methods and the entire entity?

I have a solution in Asp.net Core and, at the moment, I am refactoring the validations of the domain model.

For entities, I am using an approach based on the Specification pattern (I like it). The problem is that I would like to reuse the basic validations that are in the entity's methods in the general validation, which checks if the whole entity is valid. As my implementation of the Specification pattern receives the entire entity, I'm in doubt how to do it.

Image01

Image02

Image03

What is the most elegant way to resolve this based on my scenario?

Aucun commentaire:

Enregistrer un commentaire