Skip to content

Why is TaskRepository defined in service layer and not in domain layer? #268

Answered by MarioCarrion
JanRuettinger asked this question in Q&A
Discussion options

You must be logged in to vote

The code you're suggesting won't work because the method in the interface is unexported, see this playground; to make it work make that method exported by changing assertTaskLimit to AssertTaskLimit; also notice the new change where User is the one owning tasks not Task so this method (t *Task) NewTask aligns with the problem you described originally.

With that being said what you're describing is a User rule not a Task rule; yes Task may have rules as well, like no empty Task.Description for example, but it's the User type that owns "no more than 5 tasks a day".

So how can we enforce that rule? One way would be to define a User.Validate method that does that, it makes sure the tasks for …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MarioCarrion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #267 on March 29, 2023 01:24.