<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def direction(direction, allow_bi=False):
 """Validate that the given direction is one of the allowed constants. If ``allow_bi`` is ``True`` then ``Direction.BIDIRECTIONAL`` is acceptable. """

    valid = [Direction.CAUSE, Direction.EFFECT]
    if allow_bi:
        valid.append(Direction.BIDIRECTIONAL)

    if direction not in valid:
        raise ValueError('`direction` must be one of {}'.format(valid))

    return True