开发者

Using the speicifcation pattern as a validation layer?

开发者 https://www.devze.com 2023-02-25 21:17 出处:网络
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 inva

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 开发者_JAVA百科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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号