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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -