Creates a validator that attempts to coerce the given value to the
    specified ``type``. Will raise an error if the coercion fails.

    A custom message can be specified with ``message``.

def Coerce(type, message="Not a valid {} value"):
    """
    Creates a validator that attempts to coerce the given value to the
    specified ``type``. Will raise an error if the coercion fails.

    A custom message can be specified with ``message``.
    """
    @wraps(Coerce)
    def built(value):
        try:
            return type(value)
        except (TypeError, ValueError) as e:
            raise Error(message.format(type.__name__))
    return built