I have only seen the specification pattern used to retrieve data, but not to validate it. A colleague suggested I can use the specification pattern to “validate” an object so it does not become invalid when saving changes.
As an example, say we have a root Customer object that has a value for Address. We can track the changes to the object and create a specification that can be sent to the unit of work to make sure the address is valid (Has a physical address, city, and state) before changes are saved.
Any thoughts about this?