0

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?

DDiVita
  • 4,225
  • 5
  • 63
  • 117

1 Answers1

2

Following is a good read regarding differences between a specification and a validaton http://lostechies.com/jimmybogard/2007/10/25/specifications-versus-validators/

byte
  • 1,665
  • 1
  • 19
  • 36
  • That is a good find! Perhaps the idea of creting 2 separate specifications (one for validation and one for data access) is the way to go. Makes my head hurt ;) – DDiVita Apr 13 '11 at 16:11
  • When I first worked with Specifications I was confused between Validators and Specifications. IsValid or IsSatisfied looked familiar. Took me a while to get over it :) – byte Apr 13 '11 at 20:19