Add validation primitives to util

Part 2 in a series of changes towards data validation.
Merge pull request #311 from thockin/valid3

Add validation primitives to util