import re


def _boolify(value):
    """
    `value` should be of type bool or else a string having the value
    /yes|no|true|false/i.

    In the latter case, return a corresponding bool value.

    If already of type bool, return as is.

    If None, return None.

    If none of the above, raise a ValueError exception.

    :param str|bool value:
    :return: boolean or None
    :rtype: boolean or None
    """
    if value is not None:
        if isinstance(value, bool):
            pass
        elif re.match(r'^true|yes$', value, re.IGNORECASE):
            value = True
        elif re.match(r'^false|no$', value, re.IGNORECASE):
            value = False
        else:
            raise ValueError("Not a string-format boolean value: " + value)
    return value