EntLib 3 Validation Block Musings
Tom Hollander mentions the upcoming Validation Block slated for the next revision of Enterprise Library. Check out the announcement over here. Very cool stuff. Needed. I heard about this at the October p&p Summit (along with the potential of a block mini-factory that greatly eases custom application block development.)
From the looks of it it will serve as a kind of Specification Repository (see: Specification Pattern), in addition to providing a simple framework for validation rules such as regex, not-null, etc. I like the idea of a validation framework that works for simple forms yet still provides a consistent means of implementing custom specification-type validation.
I wonder how convenient/elegant (more the latter) it will be to build custom validators that look at object graphs.
The first thing I’d like to investigate with this is the possibility of building a concept of “severity” into custom validators. For example, I want to send this domain entity into a specification engine that will a) get all the related specifications and b) run through them serially. At the end it will produce a collection of ValidationResults that have two levels of severity. The first is “it’s okay to save this to the DB”, the second is “you can’t save this to the DB”. If savable to the database, I’d like to have a third level of severity that says “you had better not extract this record out for reporting (even though it’s in the DB)”.
I got this idea from Jimmy Nilsson’s DDD book where he expresses a preference for being able to save domain objects in the DB. Almost like saving them in a “draft mode.”
I really like that idea. Be easy on the user and having the system say ”sure you can save this object any old time, but I’m going to track that it’s not quite right to prevent you from shooting yourself in the foot.” Of course, a positive user experience would make this draft mode explicitly clear.
Post a Comment