ENH : minor generalization

 - use locals() to avoid having to know variable names
 - added 'validation_fun' to keys dict to generalize validation
   from straight casting