ENH : minor generalization

 - use locals() to avoid having to know variable names
 - added 'validation_fun' to keys dict to generalize validation
   from straight casting
Merge pull request #1 from tacaswell/type_checking

ENH : minor generalization