Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I've read the "blue book" of DDD (Evans) as well as Nilsson and am not clear what approach to validation I should take.</p> </blockquote> <p>Blue book approaches the problem from a different angle. I think that the term 'Validation' is not used because it is a dangerous <a href="http://lostechies.com/jimmybogard/2009/02/15/validation-in-a-ddd-world/" rel="nofollow noreferrer">overgeneralization</a>. A better approach is to think about <strong>object invariants</strong>, not validation. Objects (not only in DDD) should enforce their internal invariants themselves. It is not UI or services or contracts or mappers or 'validation frameworks' or anything else that is external to the objects. Invariants are enforced internally. You may find these answers helpfull: <a href="https://stackoverflow.com/questions/7093819/should-domain-objects-be-allowed-to-be-temporarily-invalid-and-how-does-that-dec/7096430#7096430">1</a>, <a href="https://stackoverflow.com/questions/6966288/ddd-client-side-validation/7019985#7019985">2</a>, <a href="https://stackoverflow.com/questions/7132468/how-to-enforce-constraint-such-as-any-field-or-specific-field-must-not-change-i/7133121#7133121">3</a>, <a href="https://stackoverflow.com/questions/7139831/bl-services-exception-or-method-result/7141395#7141395">4</a>.</p> <blockquote> <p>I could also put guards in the property setters that prevent unacceptable values from ever putting the entity into an invalid state. This would mean that AutoMapper would fail when trying to map an invalid value.</p> </blockquote> <p>You probably should not care about AutoMapper failing or using AutoMapper at all. Domain objects should encapsulate and enforce their internal invariants and throw exception if the attempt to break it is made. It is very simple and you should not compromise the simplicity and expressiveness of your domain objects because of some infrastructural issues. The goal of DDD is not to satisfy AutoMapper's or any other framework's requirements. If the framework does not work with your domain objects don't use it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload