def requiredUnless(col_name, arg, dm, df, *args):
    """
    Arg is a string in the format "str1, str2, ..."
    Each string will be a column name.
    Col_name is required in df unless each column from arg is present.
    """
    # if column name is present, no need to check if it is required
    if col_name in df.columns:
        return None
    arg_list = arg.split(",")
    arg_list = [argument.strip('"') for argument in arg_list]
    msg = ""
    for a in arg_list:
        # ignore validations that reference a different table
        if "." in a:
            continue
        if a not in df.columns:
            msg += "{} column is required unless {} is present.  ".format(col_name, a)
    if msg:
        return msg
    else:
        return None
    return None
def requiredUnless ( col_name , arg , dm , df , * args ) : if col_name in df . columns : return None arg_list = arg . split ( "," ) arg_list = [ argument . strip ( '"' ) for argument in arg_list ] msg = "" for a in arg_list : if "." in a : continue if a not in df . columns : msg += "{} column is required unless {} is present.  " . format ( col_name , a ) if msg : return msg else : return None return None
Arg is a string in the format "str1, str2, ..."
    Each string will be a column name.
    Col_name is required in df unless each column from arg is present.