Adam Warski
1 min readMar 10, 2021

--

I think that’s contradictory in a way — if a validation needs to access the database, it won’t be technology-agnostic (I suppose that’s what you meant by the term).

You can also look at validation in yet another way. Are you validating something depending on the state of the system — do you need to access the system’s context? Or is it a context-free operation?

If it’s context-free, you can put the logic in the model. Still, the question remains, where’s the right place to call that logic. That’s probably in the service, or in the command handler. So even if the logic is in the domain, you still don’t want it to be called by the framework/library code, before the service is invoked.

See also these articles:

https://enterprisecraftsmanship.com/posts/validation-and-ddd/

--

--

Adam Warski

Software engineer, Functional Programming and Scala enthusiast, SoftwareMill co-founder