'Check `val` against the type (or tuple of types) in `types`.
:raises exceptions.RequestParameterInvalidException: if not an instance.'

def type(self, key, val, types):

    if (not isinstance(val, types)):
        msg = ('must    be    a    type:    %s' % str(types))
        raise exceptions.RequestParameterInvalidException(msg, key=key, val=val)
    return val
