def chainable(fn):
    """ Make function a chainable validator

    The returned function is a chainable validator factory which takes the next
    function in the chain and returns a chained version of the original
    validator: ``fn(next(value))``.

    The chainable validators are used with the ``make_chain()`` function.
    """
    @functools.wraps(fn)
    def wrapper(nxt=lambda x: x):
        if hasattr(nxt, '__call__'):
            return lambda x: nxt(fn(x))
        # Value has been passsed directly, so we don't chain
        return fn(nxt)
    return wrapper
Make function a chainable validator

    The returned function is a chainable validator factory which takes the next
    function in the chain and returns a chained version of the original
    validator: ``fn(next(value))``.

    The chainable validators are used with the ``make_chain()`` function.