design - Domain entity validation code inside or outside the object? -
where place validation code domain entity? inside class in method validate() or outside in context object being used? or both?
if validation has consult objects inside entity put validation inside entity. person entity
- checking if age > 0 or name not empty should within entity in validate() method
- checking if course covered policy (from list of policies) involve quering/reading other course/policy objects may not related entity , should done context/service/validator outside entity
Comments
Post a Comment