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:


Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store