Closed bernadd closed 3 years ago
Example of such validation would be user email address that this repository contains.
Idea behind it is to use value object to validate the incoming data of each command, in our email address example value object EmailAddress is responsible of ensuring that its value is correct. Validation logic itself takes place during command payload being unmarshaled.
and this value object is used as a type for command properties
and events
which in this case would ensure that event payload is correct, which might be an useful feedback while replacing events to rebuild data snapshots
This seems like a really nicely structured repo for using go in microservices. However from reading around on ddd - domains layer I understand that some business logic (validation/business logic) should be applied on them and it should stick inside domain/aggregate itself and I can't see any examples of domain validation in this project/structure. Lets take as example domain job with "deadline", so user cant post a job if deadline is before specific date (ie from today + 2 weeks forward). This should be "validated" in domain layer itself (not inside command handlers) as I understand or I am wrong? If yes how would we handle/return errors on this one in domain with current structure?