Domain driven design value object, how to ensure a unique value

Posted by Darren on Stack Overflow See other posts from Stack Overflow or by Darren
Published on 2010-06-01T17:48:03Z Indexed on 2010/06/01 17:53 UTC
Read the original article Hit count: 406

Hi, I am building a questionnaire creator. A questionnaire consists of sections, sections consist of pages and pages consist of questions. Questionnaire is the aggregate root.

Sections, pages and questions can have what are called shortcodes which should be unique within a questionnaire (but not unique within the database hence they are not strictly an identity). I intended to make the shortcode a value object and wanted to include the business rule that it should be unique within the questionnaire but I am unsure how to ensure that. My understanding is that the value object should not access the repository or service layer so how does it find out if it is unique?

Thanks for any help.

Darren

© Stack Overflow or respective owner

Related posts about ddd

Related posts about ddd-repositories