def selected_features_to_constraints(feats, even_not_validated=False):
    """
    Convert a set of selected features to constraints.
    Only the features that are validated are translated into constraints,
    otherwise all are translated when `even_not_validated` is set.

    :return: str
    """
    res = ""

    for sel in reversed(feats):
        sel_str = sel['other']

        mode = sel['mode']
        if sel['validated'] or even_not_validated:
            if mode == 'selected':
                res += "[ " + sel_str + " ]" + "\n"
            elif mode == 'rejected':
                res += "[ !" + sel_str + " ]" + "\n"
    return res