redesign is_valid to support more than one type to test