username and email
The final components of our user aggregate are Username
and Email
,
which are the key values for the two User
keys. Here’s the code for
Username
:
package simbl.domain
import longevity.model.annotations.keyVal
@keyVal[SimblDomainModel, User]
case class Username(username: String)
Aside from being parts of our user aggregate, we can also embed them
in other classes. For instance, BlogPost
contains a Set[Username]
to indicate the authors of the post:
case class BlogPost(
uri: BlogPostUri,
title: String,
slug: Option[Markdown] = None,
content: Markdown,
labels: Set[String] = Set(),
postDate: DateTime,
blog: BlogUri,
authors: Set[Username])